use ::c2rust_asm_casts;
use core::arch::asm;
use c2rust_asm_casts::AsmCastTrait;
extern "C" {
pub type __lock;
pub type __locale_t;
pub type suit_storage;
static mut missing_implementation_for_fpscr_in_c2rust_see_issue_345: libc::c_int;
fn _assert_panic() -> !;
fn _clist_sort(
list_head: *mut clist_node_t,
cmp: clist_cmp_func_t,
) -> *mut clist_node_t;
static mut sched_context_switch_request: libc::c_uint;
static mut sched_threads: [*mut thread_t; 33];
static mut sched_runqueues: [clist_node_t; 16];
fn msg_send_int(m: *mut msg_t, target_pid: kernel_pid_t) -> libc::c_int;
static mut ITM_RxBuffer: int32_t;
fn measure_stack_free_internal(
stack: *const libc::c_char,
size: size_t,
) -> uintptr_t;
fn mutex_lock_internal(mutex: *mut mutex_t, block: bool) -> bool;
static mut _impure_ptr: *mut _reent;
static mut mtd_dev_xfa: [*mut mtd_dev_t; 0];
static mut mtd_dev_xfa_end: [*mut mtd_dev_t; 0];
fn gpio_set(pin: gpio_t);
fn gpio_clear(pin: gpio_t);
fn gpio_toggle(pin: gpio_t);
fn pm_off();
fn spi_transfer_bytes(
bus: spi_t,
cs: spi_cs_t,
cont: bool,
out: *const libc::c_void,
in_0: *mut libc::c_void,
len: size_t,
);
fn memcmp(
_: *const libc::c_void,
_: *const libc::c_void,
_: libc::c_uint,
) -> libc::c_int;
fn memcpy(
_: *mut libc::c_void,
_: *const libc::c_void,
_: libc::c_uint,
) -> *mut libc::c_void;
fn memset(
_: *mut libc::c_void,
_: libc::c_int,
_: libc::c_uint,
) -> *mut libc::c_void;
fn strlen(_: *const libc::c_char) -> libc::c_uint;
fn bluetil_ad_init(
ad: *mut bluetil_ad_t,
buf: *mut libc::c_void,
pos: size_t,
size: size_t,
);
fn bluetil_ad_add(
ad: *mut bluetil_ad_t,
type_0: uint8_t,
data: *const libc::c_void,
data_len: size_t,
) -> libc::c_int;
fn ztimer_is_set(
clock: *const ztimer_clock_t,
timer: *const ztimer_t,
) -> libc::c_uint;
fn _ztimer_now_extend(clock: *mut ztimer_clock_t) -> ztimer_now_t;
static ZTIMER_MSEC: *mut ztimer_clock_t;
fn event_post(queue: *mut event_queue_t, event: *mut event_t);
fn event_is_queued(queue: *const event_queue_t, event: *const event_t) -> bool;
fn event_wait_multi(queues: *mut event_queue_t, n_queues: size_t) -> *mut event_t;
fn event_callback_init(
event_callback: *mut event_callback_t,
callback: Option::<unsafe extern "C" fn(*mut libc::c_void) -> ()>,
arg: *mut libc::c_void,
);
static ipv6_addr_unspecified: ipv6_addr_t;
static ipv6_addr_loopback: ipv6_addr_t;
static ipv6_addr_link_local_prefix: ipv6_addr_t;
static ipv6_addr_all_nodes_if_local: ipv6_addr_t;
static ipv6_addr_all_routers_if_local: ipv6_addr_t;
static ipv6_addr_solicited_node_prefix: ipv6_addr_t;
fn ipv6_addr_split_str(
addr_str: *mut libc::c_char,
separator: libc::c_char,
) -> *mut libc::c_char;
fn ipv6_addr_split_int(
addr_str: *mut libc::c_char,
separator: libc::c_char,
_default: libc::c_int,
) -> libc::c_int;
fn sock_udp_create(
sock: *mut sock_udp_t,
local: *const sock_udp_ep_t,
remote: *const sock_udp_ep_t,
flags: uint16_t,
) -> libc::c_int;
fn sock_udp_close(sock: *mut sock_udp_t);
fn sock_udp_recv_aux(
sock: *mut sock_udp_t,
data: *mut libc::c_void,
max_len: size_t,
timeout: uint32_t,
remote: *mut sock_udp_ep_t,
aux: *mut sock_udp_aux_rx_t,
) -> ssize_t;
fn sock_udp_recv_buf_aux(
sock: *mut sock_udp_t,
data: *mut *mut libc::c_void,
buf_ctx: *mut *mut libc::c_void,
timeout: uint32_t,
remote: *mut sock_udp_ep_t,
aux: *mut sock_udp_aux_rx_t,
) -> ssize_t;
fn sock_udp_sendv_aux(
sock: *mut sock_udp_t,
snips: *const iolist_t,
remote: *const sock_udp_ep_t,
aux: *mut sock_udp_aux_tx_t,
) -> ssize_t;
fn _mbox_put(
mbox: *mut mbox_t,
msg: *mut msg_t,
blocking: libc::c_int,
) -> libc::c_int;
fn _mbox_get(
mbox: *mut mbox_t,
msg: *mut msg_t,
blocking: libc::c_int,
) -> libc::c_int;
fn _gnrc_netapi_send_recv(
pid: kernel_pid_t,
pkt: *mut gnrc_pktsnip_t,
type_0: uint16_t,
) -> libc::c_int;
fn _gnrc_netapi_get_set(
pid: kernel_pid_t,
opt: netopt_t,
context: uint16_t,
data: *mut libc::c_void,
data_len: size_t,
type_0: uint16_t,
) -> libc::c_int;
fn gnrc_netapi_dispatch(
type_0: gnrc_nettype_t,
demux_ctx: uint32_t,
cmd: uint16_t,
pkt: *mut gnrc_pktsnip_t,
) -> libc::c_int;
fn dhcpv6_client_conf_prefix(
netif: libc::c_uint,
pfx: *const ipv6_addr_t,
pfx_len: libc::c_uint,
valid: uint32_t,
pref: uint32_t,
);
fn dhcpv6_client_prefix_valid_until(
netif: libc::c_uint,
pfx: *const ipv6_addr_t,
pfx_len: libc::c_uint,
) -> uint32_t;
fn evtimer_init(evtimer: *mut evtimer_t, handler: evtimer_callback_t);
fn evtimer_add(evtimer: *mut evtimer_t, event: *mut evtimer_event_t);
fn l2util_ipv6_iid_to_addr(
dev_type: libc::c_int,
iid: *const eui64_t,
addr: *mut uint8_t,
) -> libc::c_int;
fn l2util_ndp_addr_len_from_l2ao(
dev_type: libc::c_int,
opt: *const ndp_opt_t,
) -> libc::c_int;
fn l2util_ipv6_group_to_l2_group(
dev_type: libc::c_int,
ipv6_group: *const ipv6_addr_t,
l2_group: *mut uint8_t,
) -> libc::c_int;
fn l2util_addr_to_str(
addr: *const uint8_t,
addr_len: size_t,
out: *mut libc::c_char,
) -> *mut libc::c_char;
fn l2util_addr_from_str(str: *const libc::c_char, out: *mut uint8_t) -> size_t;
fn netdev_register_signal(dev: *mut netdev, type_0: netdev_type_t, index: uint8_t);
fn inet_csum_slice(
sum: uint16_t,
buf: *const uint8_t,
len: uint16_t,
accum_len: size_t,
) -> uint16_t;
fn netif_get_by_name_buffer(
name: *const libc::c_char,
name_len: size_t,
) -> *mut netif_t;
fn netif_get_opt(
netif: *const netif_t,
opt: netopt_t,
context: uint16_t,
value: *mut libc::c_void,
max_len: size_t,
) -> libc::c_int;
fn gnrc_netif_get_by_pid(pid: kernel_pid_t) -> *mut gnrc_netif_t;
fn gnrc_netif_dev_is_6lo(netif: *const gnrc_netif_t) -> bool;
fn gnrc_netif_eui64_from_addr(
netif: *const gnrc_netif_t,
addr: *const uint8_t,
addr_len: size_t,
eui64: *mut eui64_t,
) -> libc::c_int;
fn gnrc_netif_ipv6_iid_from_addr(
netif: *const gnrc_netif_t,
addr: *const uint8_t,
addr_len: size_t,
iid: *mut eui64_t,
) -> libc::c_int;
fn gnrc_pktbuf_release_error(pkt: *mut gnrc_pktsnip_t, err: uint32_t);
fn timex_set(seconds: uint32_t, microseconds: uint32_t) -> timex_t;
fn sock_ip_recv_aux(
sock: *mut sock_ip_t,
data: *mut libc::c_void,
max_len: size_t,
timeout: uint32_t,
remote: *mut sock_ip_ep_t,
aux: *mut sock_ip_aux_rx_t,
) -> ssize_t;
fn sock_ip_recv_buf_aux(
sock: *mut sock_ip_t,
data: *mut *mut libc::c_void,
buf_ctx: *mut *mut libc::c_void,
timeout: uint32_t,
remote: *mut sock_ip_ep_t,
aux: *mut sock_ip_aux_rx_t,
) -> ssize_t;
fn sock_ip_send_aux(
sock: *mut sock_ip_t,
data: *const libc::c_void,
len: size_t,
proto: uint8_t,
remote: *const sock_ip_ep_t,
aux: *mut sock_ip_aux_tx_t,
) -> ssize_t;
fn bitarithm_bits_set(v: libc::c_uint) -> libc::c_uint;
fn bf_set_all(field: *mut uint8_t, size: size_t);
fn bf_clear_all(field: *mut uint8_t, size: size_t);
fn coap_opt_get_string(
pkt: *mut coap_pkt_t,
optnum: uint16_t,
target: *mut uint8_t,
max_len: size_t,
separator: libc::c_char,
) -> ssize_t;
fn coap_opt_get_opaque(
pkt: *mut coap_pkt_t,
opt_num: libc::c_uint,
value: *mut *mut uint8_t,
) -> ssize_t;
fn coap_block_finish(slicer: *mut coap_block_slicer_t, option: uint16_t) -> bool;
fn coap_get_block(
pkt: *mut coap_pkt_t,
block: *mut coap_block1_t,
option: uint16_t,
) -> libc::c_int;
fn coap_opt_add_block(
pkt: *mut coap_pkt_t,
slicer: *mut coap_block_slicer_t,
more: bool,
option: uint16_t,
) -> ssize_t;
fn coap_opt_add_uint(
pkt: *mut coap_pkt_t,
optnum: uint16_t,
value: uint32_t,
) -> ssize_t;
fn coap_opt_add_uri_query2(
pkt: *mut coap_pkt_t,
key: *const libc::c_char,
key_len: size_t,
val: *const libc::c_char,
val_len: size_t,
) -> ssize_t;
fn coap_opt_add_chars(
pkt: *mut coap_pkt_t,
optnum: uint16_t,
chars: *const libc::c_char,
chars_len: size_t,
separator: libc::c_char,
) -> ssize_t;
fn coap_opt_finish(pkt: *mut coap_pkt_t, flags: uint16_t) -> ssize_t;
fn coap_opt_remove(pkt: *mut coap_pkt_t, optnum: uint16_t) -> ssize_t;
fn coap_opt_put_block(
buf: *mut uint8_t,
lastonum: uint16_t,
slicer: *mut coap_block_slicer_t,
more: bool,
option: uint16_t,
) -> size_t;
fn coap_opt_put_uint(
buf: *mut uint8_t,
lastonum: uint16_t,
onum: uint16_t,
value: uint32_t,
) -> size_t;
fn coap_opt_put_string_with_len(
buf: *mut uint8_t,
lastonum: uint16_t,
optnum: uint16_t,
string: *const libc::c_char,
len: size_t,
separator: libc::c_char,
) -> size_t;
fn sha2xx_update(ctx: *mut sha2xx_context_t, data: *const libc::c_void, len: size_t);
fn sha2xx_final(
ctx: *mut sha2xx_context_t,
digest: *mut libc::c_void,
dig_len: size_t,
);
fn gcoap_req_init_path_buffer(
pdu: *mut coap_pkt_t,
buf: *mut uint8_t,
len: size_t,
code: libc::c_uint,
path: *const libc::c_char,
path_len: size_t,
) -> libc::c_int;
fn gcoap_req_send(
buf: *const uint8_t,
len: size_t,
remote: *const sock_udp_ep_t,
local: *const sock_udp_ep_t,
resp_handler: gcoap_resp_handler_t,
context: *mut libc::c_void,
tl_type: gcoap_socket_type_t,
) -> ssize_t;
fn gcoap_resp_init(
pdu: *mut coap_pkt_t,
buf: *mut uint8_t,
len: size_t,
code: libc::c_uint,
) -> libc::c_int;
fn printf(_: *const libc::c_char, _: ...) -> libc::c_int;
fn __srget_r(_: *mut _reent, _: *mut FILE) -> libc::c_int;
fn __swbuf_r(_: *mut _reent, _: libc::c_int, _: *mut FILE) -> libc::c_int;
fn sha512_common_update(
ctx: *mut sha512_common_context_t,
data: *const libc::c_void,
len: size_t,
);
fn sha512_common_final(
ctx: *mut sha512_common_context_t,
digest: *mut libc::c_void,
dig_len: size_t,
);
fn random_uint32() -> uint32_t;
fn sock_tl_ep_fmt(
endpoint: *const _sock_tl_ep,
addr_str: *mut libc::c_char,
port: *mut uint16_t,
) -> libc::c_int;
fn sock_urlpath(url: *const libc::c_char) -> *const libc::c_char;
fn sock_tl_str2ep(ep_out: *mut _sock_tl_ep, str: *const libc::c_char) -> libc::c_int;
fn sock_tl_name2ep(
ep_out: *mut _sock_tl_ep,
str: *const libc::c_char,
) -> libc::c_int;
fn sock_tl_ep_equal(a: *const _sock_tl_ep, b: *const _sock_tl_ep) -> bool;
fn nanocoap_sock_url_connect(
url: *const libc::c_char,
sock: *mut nanocoap_sock_t,
) -> libc::c_int;
fn shell_run_once(
commands: *const shell_command_t,
line_buf: *mut libc::c_char,
len: libc::c_int,
);
fn cose_hdr_insert(hdrs: *mut *mut cose_hdr_t, nhdr: *mut cose_hdr_t);
fn cose_cbor_decode_get_prot(
start: *const uint8_t,
len: size_t,
prot: *mut *const uint8_t,
prot_len: *mut size_t,
) -> libc::c_int;
fn cose_signature_decode_init(
signature: *mut cose_signature_dec_t,
buf: *const uint8_t,
len: size_t,
);
fn suit_worker_trigger(url: *const libc::c_char, len: size_t);
}
pub type __int8_t = libc::c_schar;
pub type __uint8_t = libc::c_uchar;
pub type __int16_t = libc::c_short;
pub type __uint16_t = libc::c_ushort;
pub type __int32_t = libc::c_int;
pub type __uint32_t = libc::c_uint;
pub type __uint64_t = libc::c_ulonglong;
pub type __uintptr_t = libc::c_uint;
pub type int8_t = __int8_t;
pub type uint8_t = __uint8_t;
pub type int16_t = __int16_t;
pub type uint16_t = __uint16_t;
pub type int32_t = __int32_t;
pub type uint32_t = __uint32_t;
pub type uint64_t = __uint64_t;
pub type uintptr_t = __uintptr_t;
pub type uint_fast8_t = libc::c_uchar;
pub type size_t = libc::c_uint;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct _reent {
pub _errno: libc::c_int,
pub _stdin: *mut __FILE,
pub _stdout: *mut __FILE,
pub _stderr: *mut __FILE,
pub _inc: libc::c_int,
pub _emergency: *mut libc::c_char,
pub __sdidinit: libc::c_int,
pub _unspecified_locale_info: libc::c_int,
pub _locale: *mut __locale_t,
pub _mp: *mut _mprec,
pub __cleanup: Option::<unsafe extern "C" fn(*mut _reent) -> ()>,
pub _gamma_signgam: libc::c_int,
pub _cvtlen: libc::c_int,
pub _cvtbuf: *mut libc::c_char,
pub _r48: *mut _rand48,
pub _localtime_buf: *mut __tm,
pub _asctime_buf: *mut libc::c_char,
pub _sig_func: *mut Option::<unsafe extern "C" fn(libc::c_int) -> ()>,
pub __sglue: _glue,
pub __sf: *mut __FILE,
pub _misc: *mut _misc_reent,
pub _signal_buf: *mut libc::c_char,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct _misc_reent {
pub _strtok_last: *mut libc::c_char,
pub _mblen_state: _mbstate_t,
pub _wctomb_state: _mbstate_t,
pub _mbtowc_state: _mbstate_t,
pub _l64a_buf: [libc::c_char; 8],
pub _getdate_err: libc::c_int,
pub _mbrlen_state: _mbstate_t,
pub _mbrtowc_state: _mbstate_t,
pub _mbsrtowcs_state: _mbstate_t,
pub _wcrtomb_state: _mbstate_t,
pub _wcsrtombs_state: _mbstate_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct _mbstate_t {
pub __count: libc::c_int,
pub __value: C2RustUnnamed,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub union C2RustUnnamed {
pub __wch: wint_t,
pub __wchb: [libc::c_uchar; 4],
}
pub type wint_t = libc::c_int;
pub type __FILE = __sFILE;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct __sFILE {
pub _p: *mut libc::c_uchar,
pub _r: libc::c_int,
pub _w: libc::c_int,
pub _flags: libc::c_short,
pub _file: libc::c_short,
pub _bf: __sbuf,
pub _lbfsize: libc::c_int,
pub _data: *mut _reent,
pub _cookie: *mut libc::c_void,
pub _read: Option::<
unsafe extern "C" fn(
*mut _reent,
*mut libc::c_void,
*mut libc::c_char,
libc::c_int,
) -> libc::c_int,
>,
pub _write: Option::<
unsafe extern "C" fn(
*mut _reent,
*mut libc::c_void,
*const libc::c_char,
libc::c_int,
) -> libc::c_int,
>,
pub _seek: Option::<
unsafe extern "C" fn(
*mut _reent,
*mut libc::c_void,
_fpos_t,
libc::c_int,
) -> _fpos_t,
>,
pub _close: Option::<
unsafe extern "C" fn(*mut _reent, *mut libc::c_void) -> libc::c_int,
>,
pub _ub: __sbuf,
pub _up: *mut libc::c_uchar,
pub _ur: libc::c_int,
pub _ubuf: [libc::c_uchar; 3],
pub _nbuf: [libc::c_uchar; 1],
pub _lb: __sbuf,
pub _blksize: libc::c_int,
pub _offset: _off_t,
pub _lock: _flock_t,
pub _mbstate: _mbstate_t,
pub _flags2: libc::c_int,
}
pub type _flock_t = _LOCK_T;
pub type _LOCK_T = *mut __lock;
pub type _off_t = libc::c_long;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct __sbuf {
pub _base: *mut libc::c_uchar,
pub _size: libc::c_int,
}
pub type _fpos_t = libc::c_long;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct _glue {
pub _next: *mut _glue,
pub _niobs: libc::c_int,
pub _iobs: *mut __FILE,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct __tm {
pub __tm_sec: libc::c_int,
pub __tm_min: libc::c_int,
pub __tm_hour: libc::c_int,
pub __tm_mday: libc::c_int,
pub __tm_mon: libc::c_int,
pub __tm_year: libc::c_int,
pub __tm_wday: libc::c_int,
pub __tm_yday: libc::c_int,
pub __tm_isdst: libc::c_int,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct _rand48 {
pub _seed: [libc::c_ushort; 3],
pub _mult: [libc::c_ushort; 3],
pub _add: libc::c_ushort,
pub _rand_next: libc::c_ulonglong,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct _mprec {
pub _result: *mut _Bigint,
pub _result_k: libc::c_int,
pub _p5s: *mut _Bigint,
pub _freelist: *mut *mut _Bigint,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct _Bigint {
pub _next: *mut _Bigint,
pub _k: libc::c_int,
pub _maxwds: libc::c_int,
pub _sign: libc::c_int,
pub _wds: libc::c_int,
pub _x: [__ULong; 1],
}
pub type __ULong = libc::c_ulong;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct list_node {
pub next: *mut list_node,
}
pub type list_node_t = list_node;
pub type clist_node_t = list_node_t;
pub type clist_cmp_func_t = Option::<
unsafe extern "C" fn(*mut clist_node_t, *mut clist_node_t) -> libc::c_int,
>;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct cib_t {
pub read_count: libc::c_uint,
pub write_count: libc::c_uint,
pub mask: libc::c_uint,
}
pub type kernel_pid_t = int16_t;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct _thread {
pub sp: *mut libc::c_char,
pub status: thread_status_t,
pub priority: uint8_t,
pub pid: kernel_pid_t,
pub flags: thread_flags_t,
pub rq_entry: clist_node_t,
pub wait_data: *mut libc::c_void,
pub msg_waiters: list_node_t,
pub msg_queue: cib_t,
pub msg_array: *mut msg_t,
pub stack_start: *mut libc::c_char,
pub name: *const libc::c_char,
pub stack_size: libc::c_int,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct msg_t {
pub sender_pid: kernel_pid_t,
pub type_0: uint16_t,
pub content: C2RustUnnamed_0,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub union C2RustUnnamed_0 {
pub ptr: *mut libc::c_void,
pub value: uint32_t,
}
pub type thread_flags_t = uint16_t;
pub type thread_status_t = libc::c_uchar;
pub const STATUS_NUMOF: thread_status_t = 13;
pub const STATUS_PENDING: thread_status_t = 12;
pub const STATUS_RUNNING: thread_status_t = 11;
pub const STATUS_COND_BLOCKED: thread_status_t = 10;
pub const STATUS_MBOX_BLOCKED: thread_status_t = 9;
pub const STATUS_FLAG_BLOCKED_ALL: thread_status_t = 8;
pub const STATUS_FLAG_BLOCKED_ANY: thread_status_t = 7;
pub const STATUS_REPLY_BLOCKED: thread_status_t = 6;
pub const STATUS_SEND_BLOCKED: thread_status_t = 5;
pub const STATUS_RECEIVE_BLOCKED: thread_status_t = 4;
pub const STATUS_MUTEX_BLOCKED: thread_status_t = 3;
pub const STATUS_SLEEPING: thread_status_t = 2;
pub const STATUS_ZOMBIE: thread_status_t = 1;
pub const STATUS_STOPPED: thread_status_t = 0;
pub type thread_t = _thread;
pub type IRQn_Type = libc::c_schar;
pub const SPIM3_IRQn: IRQn_Type = 47;
pub const PWM3_IRQn: IRQn_Type = 45;
pub const CRYPTOCELL_IRQn: IRQn_Type = 42;
pub const QSPI_IRQn: IRQn_Type = 41;
pub const UARTE1_IRQn: IRQn_Type = 40;
pub const USBD_IRQn: IRQn_Type = 39;
pub const FPU_IRQn: IRQn_Type = 38;
pub const I2S_IRQn: IRQn_Type = 37;
pub const RTC2_IRQn: IRQn_Type = 36;
pub const SPIM2_SPIS2_SPI2_IRQn: IRQn_Type = 35;
pub const PWM2_IRQn: IRQn_Type = 34;
pub const PWM1_IRQn: IRQn_Type = 33;
pub const MWU_IRQn: IRQn_Type = 32;
pub const PDM_IRQn: IRQn_Type = 29;
pub const PWM0_IRQn: IRQn_Type = 28;
pub const TIMER4_IRQn: IRQn_Type = 27;
pub const TIMER3_IRQn: IRQn_Type = 26;
pub const SWI5_EGU5_IRQn: IRQn_Type = 25;
pub const SWI4_EGU4_IRQn: IRQn_Type = 24;
pub const SWI3_EGU3_IRQn: IRQn_Type = 23;
pub const SWI2_EGU2_IRQn: IRQn_Type = 22;
pub const SWI1_EGU1_IRQn: IRQn_Type = 21;
pub const SWI0_EGU0_IRQn: IRQn_Type = 20;
pub const COMP_LPCOMP_IRQn: IRQn_Type = 19;
pub const QDEC_IRQn: IRQn_Type = 18;
pub const RTC1_IRQn: IRQn_Type = 17;
pub const WDT_IRQn: IRQn_Type = 16;
pub const CCM_AAR_IRQn: IRQn_Type = 15;
pub const ECB_IRQn: IRQn_Type = 14;
pub const RNG_IRQn: IRQn_Type = 13;
pub const TEMP_IRQn: IRQn_Type = 12;
pub const RTC0_IRQn: IRQn_Type = 11;
pub const TIMER2_IRQn: IRQn_Type = 10;
pub const TIMER1_IRQn: IRQn_Type = 9;
pub const TIMER0_IRQn: IRQn_Type = 8;
pub const SAADC_IRQn: IRQn_Type = 7;
pub const GPIOTE_IRQn: IRQn_Type = 6;
pub const NFCT_IRQn: IRQn_Type = 5;
pub const SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQn: IRQn_Type = 4;
pub const SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQn: IRQn_Type = 3;
pub const UARTE0_UART0_IRQn: IRQn_Type = 2;
pub const RADIO_IRQn: IRQn_Type = 1;
pub const POWER_CLOCK_IRQn: IRQn_Type = 0;
pub const SysTick_IRQn: IRQn_Type = -1;
pub const PendSV_IRQn: IRQn_Type = -2;
pub const DebugMonitor_IRQn: IRQn_Type = -4;
pub const SVCall_IRQn: IRQn_Type = -5;
pub const UsageFault_IRQn: IRQn_Type = -10;
pub const BusFault_IRQn: IRQn_Type = -11;
pub const MemoryManagement_IRQn: IRQn_Type = -12;
pub const HardFault_IRQn: IRQn_Type = -13;
pub const NonMaskableInt_IRQn: IRQn_Type = -14;
pub const Reset_IRQn: IRQn_Type = -15;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct __zero_table_t {
pub dest: *mut uint32_t,
pub wlen: uint32_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct __copy_table_t {
pub src: *const uint32_t,
pub dest: *mut uint32_t,
pub wlen: uint32_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub union llreg_u {
pub w32: [uint32_t; 2],
pub w64: uint64_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub union llreg_u_0 {
pub w32: [uint32_t; 2],
pub w64: uint64_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub union llreg_u_1 {
pub w32: [uint32_t; 2],
pub w64: uint64_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub union llreg_u_2 {
pub w32: [uint32_t; 2],
pub w64: uint64_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct NVIC_Type {
pub ISER: [uint32_t; 8],
pub RESERVED0: [uint32_t; 24],
pub ICER: [uint32_t; 8],
pub RESERVED1: [uint32_t; 24],
pub ISPR: [uint32_t; 8],
pub RESERVED2: [uint32_t; 24],
pub ICPR: [uint32_t; 8],
pub RESERVED3: [uint32_t; 24],
pub IABR: [uint32_t; 8],
pub RESERVED4: [uint32_t; 56],
pub IP: [uint8_t; 240],
pub RESERVED5: [uint32_t; 644],
pub STIR: uint32_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct SCB_Type {
pub CPUID: uint32_t,
pub ICSR: uint32_t,
pub VTOR: uint32_t,
pub AIRCR: uint32_t,
pub SCR: uint32_t,
pub CCR: uint32_t,
pub SHP: [uint8_t; 12],
pub SHCSR: uint32_t,
pub CFSR: uint32_t,
pub HFSR: uint32_t,
pub DFSR: uint32_t,
pub MMFAR: uint32_t,
pub BFAR: uint32_t,
pub AFSR: uint32_t,
pub PFR: [uint32_t; 2],
pub DFR: uint32_t,
pub ADR: uint32_t,
pub MMFR: [uint32_t; 4],
pub ISAR: [uint32_t; 5],
pub RESERVED0: [uint32_t; 5],
pub CPACR: uint32_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct SysTick_Type {
pub CTRL: uint32_t,
pub LOAD: uint32_t,
pub VAL: uint32_t,
pub CALIB: uint32_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct ITM_Type {
pub PORT: [C2RustUnnamed_1; 32],
pub RESERVED0: [uint32_t; 864],
pub TER: uint32_t,
pub RESERVED1: [uint32_t; 15],
pub TPR: uint32_t,
pub RESERVED2: [uint32_t; 15],
pub TCR: uint32_t,
pub RESERVED3: [uint32_t; 32],
pub RESERVED4: [uint32_t; 43],
pub LAR: uint32_t,
pub LSR: uint32_t,
pub RESERVED5: [uint32_t; 6],
pub PID4: uint32_t,
pub PID5: uint32_t,
pub PID6: uint32_t,
pub PID7: uint32_t,
pub PID0: uint32_t,
pub PID1: uint32_t,
pub PID2: uint32_t,
pub PID3: uint32_t,
pub CID0: uint32_t,
pub CID1: uint32_t,
pub CID2: uint32_t,
pub CID3: uint32_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub union C2RustUnnamed_1 {
pub u8_0: uint8_t,
pub u16_0: uint16_t,
pub u32_0: uint32_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct MPU_Type {
pub TYPE: uint32_t,
pub CTRL: uint32_t,
pub RNR: uint32_t,
pub RBAR: uint32_t,
pub RASR: uint32_t,
pub RBAR_A1: uint32_t,
pub RASR_A1: uint32_t,
pub RBAR_A2: uint32_t,
pub RASR_A2: uint32_t,
pub RBAR_A3: uint32_t,
pub RASR_A3: uint32_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct FPU_Type {
pub RESERVED0: [uint32_t; 1],
pub FPCCR: uint32_t,
pub FPCAR: uint32_t,
pub FPDSCR: uint32_t,
pub MVFR0: uint32_t,
pub MVFR1: uint32_t,
pub MVFR2: uint32_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct ARM_MPU_Region_t {
pub RBAR: uint32_t,
pub RASR: uint32_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct mutex_t {
pub queue: list_node_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct mutex_cancel_t {
pub mutex: *mut mutex_t,
pub thread: *mut thread_t,
pub cancelled: uint8_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct rmutex_t {
pub mutex: mutex_t,
pub refcount: uint16_t,
pub owner: kernel_pid_t,
}
pub type _ssize_t = libc::c_int;
pub type __timer_t = libc::c_ulong;
pub type ssize_t = _ssize_t;
pub type timer_t = __timer_t;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct iolist {
pub iol_next: *mut iolist_t,
pub iol_base: *mut libc::c_void,
pub iol_len: size_t,
}
pub type iolist_t = iolist;
pub type mtd_power_state = libc::c_uchar;
pub const MTD_POWER_DOWN: mtd_power_state = 1;
pub const MTD_POWER_UP: mtd_power_state = 0;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct mtd_desc {
pub init: Option::<unsafe extern "C" fn(*mut mtd_dev_t) -> libc::c_int>,
pub read: Option::<
unsafe extern "C" fn(
*mut mtd_dev_t,
*mut libc::c_void,
uint32_t,
uint32_t,
) -> libc::c_int,
>,
pub read_page: Option::<
unsafe extern "C" fn(
*mut mtd_dev_t,
*mut libc::c_void,
uint32_t,
uint32_t,
uint32_t,
) -> libc::c_int,
>,
pub write_page: Option::<
unsafe extern "C" fn(
*mut mtd_dev_t,
*const libc::c_void,
uint32_t,
uint32_t,
uint32_t,
) -> libc::c_int,
>,
pub erase: Option::<
unsafe extern "C" fn(*mut mtd_dev_t, uint32_t, uint32_t) -> libc::c_int,
>,
pub erase_sector: Option::<
unsafe extern "C" fn(*mut mtd_dev_t, uint32_t, uint32_t) -> libc::c_int,
>,
pub power: Option::<
unsafe extern "C" fn(*mut mtd_dev_t, mtd_power_state) -> libc::c_int,
>,
pub flags: uint8_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct mtd_dev_t {
pub driver: *const mtd_desc_t,
pub sector_count: uint32_t,
pub pages_per_sector: uint32_t,
pub page_size: uint32_t,
pub write_size: uint32_t,
}
pub type mtd_desc_t = mtd_desc;
pub type gpio_t = uint8_t;
pub type adc_t = uint_fast8_t;
pub type i2c_t = uint_fast8_t;
pub type pwm_t = uint_fast8_t;
pub type spi_t = uint_fast8_t;
pub type spi_cs_t = gpio_t;
pub type uart_t = uint_fast8_t;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct bluetil_ad_t {
pub buf: *mut uint8_t,
pub pos: size_t,
pub size: size_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct ztimer_base {
pub next: *mut ztimer_base_t,
pub offset: uint32_t,
}
pub type ztimer_base_t = ztimer_base;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct ztimer_clock {
pub list: ztimer_base_t,
pub ops: *const ztimer_ops_t,
pub last: *mut ztimer_base_t,
pub adjust_set: uint16_t,
pub adjust_sleep: uint16_t,
pub max_value: uint32_t,
pub lower_last: uint32_t,
pub checkpoint: ztimer_now_t,
}
pub type ztimer_now_t = uint32_t;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct ztimer_ops_t {
pub set: Option::<unsafe extern "C" fn(*mut ztimer_clock_t, uint32_t) -> ()>,
pub now: Option::<unsafe extern "C" fn(*mut ztimer_clock_t) -> uint32_t>,
pub cancel: Option::<unsafe extern "C" fn(*mut ztimer_clock_t) -> ()>,
}
pub type ztimer_clock_t = ztimer_clock;
pub type ztimer_callback_t = Option::<unsafe extern "C" fn(*mut libc::c_void) -> ()>;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct ztimer_t {
pub base: ztimer_base_t,
pub callback: ztimer_callback_t,
pub arg: *mut libc::c_void,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct event {
pub list_node: clist_node_t,
pub handler: event_handler_t,
}
pub type event_handler_t = Option::<unsafe extern "C" fn(*mut event_t) -> ()>;
pub type event_t = event;
#[derive(Copy, Clone)]
#[repr(C, align(4))]
pub struct event_queue_t(pub event_queue_t_Inner);
#[derive(Copy, Clone)]
#[repr(C)]
pub struct event_queue_t_Inner {
pub event_list: clist_node_t,
pub waiter: *mut thread_t,
}
#[allow(dead_code, non_upper_case_globals)]
const event_queue_t_PADDING: usize = ::core::mem::size_of::<event_queue_t>()
- ::core::mem::size_of::<event_queue_t_Inner>();
#[derive(Copy, Clone)]
#[repr(C)]
pub struct event_callback_t {
pub super_0: event_t,
pub callback: Option::<unsafe extern "C" fn(*mut libc::c_void) -> ()>,
pub arg: *mut libc::c_void,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct event_timeout_t {
pub clock: *mut ztimer_clock_t,
pub timer: ztimer_t,
pub queue: *mut event_queue_t,
pub event: *mut event_t,
}
#[derive(Copy, Clone)]
#[repr(C, packed)]
pub struct uint16_una_t {
pub val: uint16_t,
}
#[derive(Copy, Clone)]
#[repr(C, packed)]
pub struct uint32_una_t {
pub val: uint32_t,
}
#[derive(Copy, Clone)]
#[repr(C, packed)]
pub struct uint64_una_t {
pub val: uint64_t,
}
#[derive(Copy, Clone)]
#[repr(C, packed)]
pub union le_uint16_t {
pub u16_0: uint16_t,
pub u8_0: [uint8_t; 2],
}
#[derive(Copy, Clone)]
#[repr(C, packed)]
pub union le_uint32_t {
pub u32_0: uint32_t,
pub u8_0: [uint8_t; 4],
pub u16_0: [uint16_t; 2],
pub l16: [le_uint16_t; 2],
}
#[derive(Copy, Clone)]
#[repr(C, packed)]
pub union le_uint64_t {
pub u64_0: uint64_t,
pub u8_0: [uint8_t; 8],
pub u16_0: [uint16_t; 4],
pub u32_0: [uint32_t; 2],
pub l16: [le_uint16_t; 4],
pub l32: [le_uint32_t; 2],
}
#[derive(Copy, Clone)]
#[repr(C, packed)]
pub union be_uint16_t {
pub u16_0: uint16_t,
pub u8_0: [uint8_t; 2],
}
#[derive(Copy, Clone)]
#[repr(C, packed)]
pub union be_uint32_t {
pub u32_0: uint32_t,
pub u8_0: [uint8_t; 4],
pub u16_0: [uint16_t; 2],
pub b16: [be_uint16_t; 2],
}
#[derive(Copy, Clone)]
#[repr(C, packed)]
pub union be_uint64_t {
pub u64_0: uint64_t,
pub u8_0: [uint8_t; 8],
pub u16_0: [uint16_t; 4],
pub u32_0: [uint32_t; 2],
pub b16: [be_uint16_t; 4],
pub b32: [be_uint32_t; 2],
}
pub type network_uint16_t = be_uint16_t;
pub type network_uint32_t = be_uint32_t;
pub type network_uint64_t = be_uint64_t;
#[derive(Copy, Clone)]
#[repr(C)]
pub union ipv4_addr_t {
pub u8_0: [uint8_t; 4],
pub u32_0: network_uint32_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub union ipv6_addr_t {
pub u8_0: [uint8_t; 16],
pub u16_0: [network_uint16_t; 8],
pub u32_0: [network_uint32_t; 4],
pub u64_0: [network_uint64_t; 2],
}
pub type C2RustUnnamed_2 = libc::c_uchar;
pub const AF_NUMOF: C2RustUnnamed_2 = 5;
pub const AF_INET6: C2RustUnnamed_2 = 4;
pub const AF_INET: C2RustUnnamed_2 = 3;
pub const AF_PACKET: C2RustUnnamed_2 = 2;
pub const AF_UNIX: C2RustUnnamed_2 = 1;
pub const AF_UNSPEC: C2RustUnnamed_2 = 0;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct sock_ip_ep_t {
pub family: libc::c_int,
pub addr: C2RustUnnamed_3,
pub netif: uint16_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub union C2RustUnnamed_3 {
pub ipv6: [uint8_t; 16],
pub ipv4: [uint8_t; 4],
pub ipv4_u32: uint32_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct _sock_tl_ep {
pub family: libc::c_int,
pub addr: C2RustUnnamed_4,
pub netif: uint16_t,
pub port: uint16_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub union C2RustUnnamed_4 {
pub ipv6: [uint8_t; 16],
pub ipv4: [uint8_t; 4],
pub ipv4_u32: uint32_t,
}
pub type sock_aux_flags_t = uint8_t;
pub type sock_udp_ep_t = _sock_tl_ep;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct sock_udp {
pub reg: gnrc_sock_reg_t,
pub local: sock_udp_ep_t,
pub remote: sock_udp_ep_t,
pub flags: uint16_t,
}
pub type gnrc_sock_reg_t = gnrc_sock_reg;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct gnrc_sock_reg {
pub entry: gnrc_netreg_entry_t,
pub mbox: mbox_t,
pub mbox_queue: [msg_t; 8],
pub netreg_cb: gnrc_netreg_entry_cbd_t,
pub async_cb: C2RustUnnamed_5,
pub async_cb_arg: *mut libc::c_void,
pub async_ctx: sock_async_ctx_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct sock_async_ctx_t {
pub event: sock_event_t,
pub queue: *mut event_queue_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct sock_event_t {
pub super_0: event_t,
pub cb: sock_event_cb_t,
pub sock: *mut libc::c_void,
pub cb_arg: *mut libc::c_void,
pub type_0: sock_async_flags_t,
}
pub type sock_async_flags_t = libc::c_uchar;
pub const SOCK_ASYNC_PATH_PROP: sock_async_flags_t = 64;
pub const SOCK_ASYNC_MSG_SENT: sock_async_flags_t = 32;
pub const SOCK_ASYNC_MSG_RECV: sock_async_flags_t = 16;
pub const SOCK_ASYNC_CONN_RECV: sock_async_flags_t = 4;
pub const SOCK_ASYNC_CONN_FIN: sock_async_flags_t = 2;
pub const SOCK_ASYNC_CONN_RDY: sock_async_flags_t = 1;
#[derive(Copy, Clone)]
#[repr(C)]
pub union sock_event_cb_t {
pub generic: Option::<
unsafe extern "C" fn(
*mut libc::c_void,
sock_async_flags_t,
*mut libc::c_void,
) -> (),
>,
pub tcp: sock_tcp_cb_t,
pub tcp_queue: sock_tcp_queue_cb_t,
pub udp: sock_udp_cb_t,
}
pub type sock_udp_cb_t = Option::<
unsafe extern "C" fn(*mut sock_udp_t, sock_async_flags_t, *mut libc::c_void) -> (),
>;
pub type sock_udp_t = sock_udp;
pub type sock_tcp_queue_cb_t = Option::<
unsafe extern "C" fn(
*mut sock_tcp_queue_t,
sock_async_flags_t,
*mut libc::c_void,
) -> (),
>;
pub type sock_tcp_queue_t = sock_tcp_queue;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct sock_tcp_queue {
pub lock: mutex_t,
pub tcbs: *mut gnrc_tcp_tcb_t,
pub tcbs_len: size_t,
}
pub type gnrc_tcp_tcb_t = sock_tcp;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct sock_tcp {
pub address_family: uint8_t,
pub local_addr: [uint8_t; 16],
pub peer_addr: [uint8_t; 16],
pub ll_iface: int8_t,
pub local_port: uint16_t,
pub peer_port: uint16_t,
pub state: uint8_t,
pub status: uint8_t,
pub snd_una: uint32_t,
pub snd_nxt: uint32_t,
pub snd_wnd: uint16_t,
pub snd_wl1: uint32_t,
pub snd_wl2: uint32_t,
pub rcv_nxt: uint32_t,
pub rcv_wnd: uint16_t,
pub iss: uint32_t,
pub irs: uint32_t,
pub mss: uint16_t,
pub rtt_start: uint32_t,
pub rtt_var: int32_t,
pub srtt: int32_t,
pub rto: int32_t,
pub retries: uint8_t,
pub event_retransmit: evtimer_msg_event_t,
pub event_timeout: evtimer_msg_event_t,
pub event_misc: evtimer_mbox_event_t,
pub pkt_retransmit: *mut gnrc_pktsnip_t,
pub mbox: *mut mbox_t,
pub rcv_buf_raw: *mut uint8_t,
pub rcv_buf: ringbuffer_t,
pub fsm_lock: mutex_t,
pub function_lock: mutex_t,
pub next: *mut sock_tcp,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct ringbuffer_t {
pub buf: *mut libc::c_char,
pub size: libc::c_uint,
pub start: libc::c_uint,
pub avail: libc::c_uint,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct mbox_t {
pub readers: list_node_t,
pub writers: list_node_t,
pub cib: cib_t,
pub msg_array: *mut msg_t,
}
pub type gnrc_pktsnip_t = gnrc_pktsnip;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct gnrc_pktsnip {
pub next: *mut gnrc_pktsnip,
pub data: *mut libc::c_void,
pub size: size_t,
pub type_0: gnrc_nettype_t,
pub users: uint8_t,
}
pub type gnrc_nettype_t = libc::c_schar;
pub const GNRC_NETTYPE_NUMOF: gnrc_nettype_t = 5;
pub const GNRC_NETTYPE_UDP: gnrc_nettype_t = 4;
pub const GNRC_NETTYPE_TCP: gnrc_nettype_t = 3;
pub const GNRC_NETTYPE_ICMPV6: gnrc_nettype_t = 2;
pub const GNRC_NETTYPE_IPV6: gnrc_nettype_t = 1;
pub const GNRC_NETTYPE_UNDEF: gnrc_nettype_t = 0;
pub const GNRC_NETTYPE_NETIF: gnrc_nettype_t = -1;
pub const GNRC_NETTYPE_TX_SYNC: gnrc_nettype_t = -3;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct evtimer_mbox_event_t {
pub event: evtimer_event_t,
pub msg: msg_t,
pub mbox: *mut mbox_t,
}
pub type evtimer_event_t = evtimer_event;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct evtimer_event {
pub next: *mut evtimer_event,
pub offset: uint32_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct evtimer_msg_event_t {
pub event: evtimer_event_t,
pub msg: msg_t,
}
pub type sock_tcp_cb_t = Option::<
unsafe extern "C" fn(*mut sock_tcp_t, sock_async_flags_t, *mut libc::c_void) -> (),
>;
pub type sock_tcp_t = sock_tcp;
#[derive(Copy, Clone)]
#[repr(C)]
pub union C2RustUnnamed_5 {
pub generic: gnrc_sock_reg_cb_t,
pub udp: sock_udp_cb_t,
}
pub type gnrc_sock_reg_cb_t = Option::<
unsafe extern "C" fn(
*mut gnrc_sock_reg_t,
sock_async_flags_t,
*mut libc::c_void,
) -> (),
>;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct gnrc_netreg_entry_cbd_t {
pub cb: gnrc_netreg_entry_cb_t,
pub ctx: *mut libc::c_void,
}
pub type gnrc_netreg_entry_cb_t = Option::<
unsafe extern "C" fn(uint16_t, *mut gnrc_pktsnip_t, *mut libc::c_void) -> (),
>;
pub type gnrc_netreg_entry_t = gnrc_netreg_entry;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct gnrc_netreg_entry {
pub next: *mut gnrc_netreg_entry,
pub demux_ctx: uint32_t,
pub type_0: gnrc_netreg_type_t,
pub target: C2RustUnnamed_6,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub union C2RustUnnamed_6 {
pub pid: kernel_pid_t,
pub mbox: *mut mbox_t,
pub cbd: *mut gnrc_netreg_entry_cbd_t,
}
pub type gnrc_netreg_type_t = libc::c_uchar;
pub const GNRC_NETREG_TYPE_CB: gnrc_netreg_type_t = 2;
pub const GNRC_NETREG_TYPE_MBOX: gnrc_netreg_type_t = 1;
pub const GNRC_NETREG_TYPE_DEFAULT: gnrc_netreg_type_t = 0;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct sock_udp_aux_rx_t {
pub local: sock_udp_ep_t,
pub flags: sock_aux_flags_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct sock_udp_aux_tx_t {
pub local: sock_udp_ep_t,
pub flags: sock_aux_flags_t,
}
pub type C2RustUnnamed_7 = libc::c_uchar;
pub const BLOCKING: C2RustUnnamed_7 = 1;
pub const NON_BLOCKING: C2RustUnnamed_7 = 0;
pub type netopt_t = libc::c_uchar;
pub const NETOPT_NUMOF: netopt_t = 115;
pub const NETOPT_GTS_TX: netopt_t = 114;
pub const NETOPT_GTS_ALLOC: netopt_t = 113;
pub const NETOPT_PAN_COORD: netopt_t = 112;
pub const NETOPT_L2_GROUP_LEAVE: netopt_t = 111;
pub const NETOPT_L2_GROUP: netopt_t = 110;
pub const NETOPT_BATMON: netopt_t = 109;
pub const NETOPT_DISCONNECT: netopt_t = 108;
pub const NETOPT_CONNECT: netopt_t = 107;
pub const NETOPT_SCAN: netopt_t = 106;
pub const NETOPT_RSSI: netopt_t = 105;
pub const NETOPT_LINK_CHECK: netopt_t = 104;
pub const NETOPT_NUM_GATEWAYS: netopt_t = 103;
pub const NETOPT_DEMOD_MARGIN: netopt_t = 102;
pub const NETOPT_OTAA: netopt_t = 101;
pub const NETOPT_RX_SYMBOL_TIMEOUT: netopt_t = 100;
pub const NETOPT_RANDOM: netopt_t = 99;
pub const NETOPT_SYNCWORD: netopt_t = 98;
pub const NETOPT_CHANNEL_SPACING: netopt_t = 97;
pub const NETOPT_MR_FSK_FEC: netopt_t = 96;
pub const NETOPT_MR_FSK_SRATE: netopt_t = 95;
pub const NETOPT_MR_FSK_MODULATION_ORDER: netopt_t = 94;
pub const NETOPT_MR_FSK_MODULATION_INDEX: netopt_t = 93;
pub const NETOPT_MR_OFDM_MCS: netopt_t = 92;
pub const NETOPT_MR_OFDM_OPTION: netopt_t = 91;
pub const NETOPT_MR_OQPSK_RATE: netopt_t = 90;
pub const NETOPT_MR_OQPSK_CHIPS: netopt_t = 89;
pub const NETOPT_OQPSK_RATE: netopt_t = 88;
pub const NETOPT_IEEE802154_PHY: netopt_t = 87;
pub const NETOPT_LORAWAN_MIN_RX_SYMBOL: netopt_t = 86;
pub const NETOPT_LORAWAN_MAX_RX_ERROR: netopt_t = 85;
pub const NETOPT_LORAWAN_RX2_FREQ: netopt_t = 84;
pub const NETOPT_LORAWAN_RX2_DR: netopt_t = 83;
pub const NETOPT_LORAWAN_PUBLIC_NETWORK: netopt_t = 82;
pub const NETOPT_LORAWAN_ADR: netopt_t = 81;
pub const NETOPT_LORAWAN_DR: netopt_t = 80;
pub const NETOPT_LORAWAN_DEVICE_CLASS: netopt_t = 79;
pub const NETOPT_LORAWAN_NWKSENCKEY: netopt_t = 78;
pub const NETOPT_LORAWAN_SNWKSINTKEY: netopt_t = 77;
pub const NETOPT_LORAWAN_FNWKSINTKEY: netopt_t = 76;
pub const NETOPT_LORAWAN_APPSKEY: netopt_t = 75;
pub const NETOPT_LORAWAN_NWKSKEY: netopt_t = 74;
pub const NETOPT_LORAWAN_NWKKEY: netopt_t = 73;
pub const NETOPT_LORAWAN_APPKEY: netopt_t = 72;
pub const NETOPT_LORAWAN_JOINEUI: netopt_t = 71;
pub const NETOPT_LORAWAN_APPEUI: netopt_t = 70;
pub const NETOPT_PHY_BUSY: netopt_t = 69;
pub const NETOPT_CHECKSUM: netopt_t = 68;
pub const NETOPT_BLE_CTX: netopt_t = 67;
pub const NETOPT_TX_RETRIES_NEEDED: netopt_t = 66;
pub const NETOPT_6LO_IPHC: netopt_t = 65;
pub const NETOPT_6LO: netopt_t = 64;
pub const NETOPT_IQ_INVERT: netopt_t = 63;
pub const NETOPT_FIXED_HEADER: netopt_t = 62;
pub const NETOPT_CODING_RATE: netopt_t = 61;
pub const NETOPT_SPREADING_FACTOR: netopt_t = 60;
pub const NETOPT_BANDWIDTH: netopt_t = 59;
pub const NETOPT_TX_TIMEOUT: netopt_t = 58;
pub const NETOPT_RX_TIMEOUT: netopt_t = 57;
pub const NETOPT_SINGLE_RECEIVE: netopt_t = 56;
pub const NETOPT_CHANNEL_HOP_PERIOD: netopt_t = 55;
pub const NETOPT_CHANNEL_HOP: netopt_t = 54;
pub const NETOPT_CHANNEL_FREQUENCY: netopt_t = 53;
pub const NETOPT_INTEGRITY_CHECK: netopt_t = 52;
pub const NETOPT_PREAMBLE_LENGTH: netopt_t = 51;
pub const NETOPT_LAST_ED_LEVEL: netopt_t = 50;
pub const NETOPT_L2FILTER_RM: netopt_t = 49;
pub const NETOPT_L2FILTER: netopt_t = 48;
pub const NETOPT_RF_TESTMODE: netopt_t = 47;
pub const NETOPT_ENCRYPTION_KEY: netopt_t = 46;
pub const NETOPT_ENCRYPTION: netopt_t = 45;
pub const NETOPT_STATS: netopt_t = 44;
pub const NETOPT_CCA_MODE: netopt_t = 43;
pub const NETOPT_CCA_THRESHOLD: netopt_t = 42;
pub const NETOPT_CHANNEL_PAGE: netopt_t = 41;
pub const NETOPT_DEVICE_TYPE: netopt_t = 40;
pub const NETOPT_IS_WIRED: netopt_t = 39;
pub const NETOPT_MAC_NO_SLEEP: netopt_t = 38;
pub const NETOPT_CSMA_MINBE: netopt_t = 37;
pub const NETOPT_CSMA_MAXBE: netopt_t = 36;
pub const NETOPT_CSMA_RETRIES: netopt_t = 35;
pub const NETOPT_CSMA: netopt_t = 34;
pub const NETOPT_ACTIVE: netopt_t = 33;
pub const NETOPT_LINK: netopt_t = 32;
pub const NETOPT_AUTOCCA: netopt_t = 31;
pub const NETOPT_TX_END_IRQ: netopt_t = 30;
pub const NETOPT_TX_START_IRQ: netopt_t = 29;
pub const NETOPT_RX_START_IRQ: netopt_t = 28;
pub const NETOPT_RAWMODE: netopt_t = 27;
pub const NETOPT_STATE: netopt_t = 26;
pub const NETOPT_PROTO: netopt_t = 25;
pub const NETOPT_RETRANS: netopt_t = 24;
pub const NETOPT_ACK_REQ: netopt_t = 23;
pub const NETOPT_ACK_PENDING: netopt_t = 22;
pub const NETOPT_AUTOACK: netopt_t = 21;
pub const NETOPT_PROMISCUOUSMODE: netopt_t = 20;
pub const NETOPT_PRELOADING: netopt_t = 19;
pub const NETOPT_PDU_SIZE: netopt_t = 18;
pub const NETOPT_MAX_PDU_SIZE: netopt_t = 17;
pub const NETOPT_TX_POWER: netopt_t = 16;
pub const NETOPT_IPV6_SND_RTR_ADV: netopt_t = 15;
pub const NETOPT_IPV6_FORWARDING: netopt_t = 14;
pub const NETOPT_IPV6_GROUP_LEAVE: netopt_t = 13;
pub const NETOPT_IPV6_GROUP: netopt_t = 12;
pub const NETOPT_IPV6_ADDR_FLAGS: netopt_t = 11;
pub const NETOPT_IPV6_ADDR_REMOVE: netopt_t = 10;
pub const NETOPT_IPV6_ADDR: netopt_t = 9;
pub const NETOPT_IPV6_IID: netopt_t = 8;
pub const NETOPT_HOP_LIMIT: netopt_t = 7;
pub const NETOPT_NID: netopt_t = 6;
pub const NETOPT_SRC_LEN: netopt_t = 5;
pub const NETOPT_ADDR_LEN: netopt_t = 4;
pub const NETOPT_ADDRESS_LONG: netopt_t = 3;
pub const NETOPT_ADDRESS: netopt_t = 2;
pub const NETOPT_IS_CHANNEL_CLR: netopt_t = 1;
pub const NETOPT_CHANNEL: netopt_t = 0;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct gnrc_netapi_opt_t {
pub opt: netopt_t,
pub context: uint16_t,
pub data: *mut libc::c_void,
pub data_len: uint16_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub union eui64_t {
pub uint64: network_uint64_t,
pub uint8: [uint8_t; 8],
pub uint16: [network_uint16_t; 4],
pub uint32: [network_uint32_t; 2],
}
pub type evtimer_callback_t = Option::<unsafe extern "C" fn(*mut evtimer_event_t) -> ()>;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct evtimer_t {
pub timer: ztimer_t,
pub base: uint32_t,
pub callback: evtimer_callback_t,
pub events: *mut evtimer_event_t,
}
pub type evtimer_msg_t = evtimer_t;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct gnrc_netif_ipv6_t {
pub addrs_flags: [uint8_t; 2],
pub addrs: [ipv6_addr_t; 2],
pub groups: [ipv6_addr_t; 3],
pub recalc_reach_time: evtimer_msg_event_t,
pub search_rtr: evtimer_msg_event_t,
pub addrs_timers: [evtimer_msg_event_t; 2],
pub reach_time_base: uint32_t,
pub reach_time: uint32_t,
pub retrans_time: uint32_t,
pub rs_sent: uint8_t,
pub na_sent: uint8_t,
pub aac_mode: uint8_t,
pub mtu: uint16_t,
}
#[derive(Copy, Clone)]
#[repr(C, packed)]
pub struct ndp_opt_t {
pub type_0: uint8_t,
pub len: uint8_t,
}
pub type netdev_event_t = libc::c_uchar;
pub const NETDEV_EVENT_CAD_DONE: netdev_event_t = 11;
pub const NETDEV_EVENT_FHSS_CHANGE_CHANNEL: netdev_event_t = 10;
pub const NETDEV_EVENT_CRC_ERROR: netdev_event_t = 9;
pub const NETDEV_EVENT_RX_TIMEOUT: netdev_event_t = 8;
pub const NETDEV_EVENT_TX_TIMEOUT: netdev_event_t = 7;
pub const NETDEV_EVENT_LINK_DOWN: netdev_event_t = 6;
pub const NETDEV_EVENT_LINK_UP: netdev_event_t = 5;
pub const NETDEV_EVENT_TX_COMPLETE: netdev_event_t = 4;
pub const NETDEV_EVENT_TX_STARTED: netdev_event_t = 3;
pub const NETDEV_EVENT_RX_COMPLETE: netdev_event_t = 2;
pub const NETDEV_EVENT_RX_STARTED: netdev_event_t = 1;
pub const NETDEV_EVENT_ISR: netdev_event_t = 0;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct netdev {
pub driver: *const netdev_driver,
pub event_callback: netdev_event_cb_t,
pub context: *mut libc::c_void,
}
pub type netdev_event_cb_t = Option::<
unsafe extern "C" fn(*mut netdev_t, netdev_event_t) -> (),
>;
pub type netdev_t = netdev;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct netdev_driver {
pub send: Option::<
unsafe extern "C" fn(*mut netdev_t, *const iolist_t) -> libc::c_int,
>,
pub confirm_send: Option::<
unsafe extern "C" fn(*mut netdev_t, *mut libc::c_void) -> libc::c_int,
>,
pub recv: Option::<
unsafe extern "C" fn(
*mut netdev_t,
*mut libc::c_void,
size_t,
*mut libc::c_void,
) -> libc::c_int,
>,
pub init: Option::<unsafe extern "C" fn(*mut netdev_t) -> libc::c_int>,
pub isr: Option::<unsafe extern "C" fn(*mut netdev_t) -> ()>,
pub get: Option::<
unsafe extern "C" fn(
*mut netdev_t,
netopt_t,
*mut libc::c_void,
size_t,
) -> libc::c_int,
>,
pub set: Option::<
unsafe extern "C" fn(
*mut netdev_t,
netopt_t,
*const libc::c_void,
size_t,
) -> libc::c_int,
>,
}
pub type netdev_type_t = libc::c_uchar;
pub const NETDEV_W5500: netdev_type_t = 30;
pub const NETDEV_TINYUSB: netdev_type_t = 29;
pub const NETDEV_CDC_ECM: netdev_type_t = 28;
pub const NETDEV_ESP_WIFI: netdev_type_t = 27;
pub const NETDEV_ESP_ETH: netdev_type_t = 26;
pub const NETDEV_KW2XRF: netdev_type_t = 25;
pub const NETDEV_ATWINC15X0: netdev_type_t = 24;
pub const NETDEV_ENCX24J600: netdev_type_t = 23;
pub const NETDEV_W5100: netdev_type_t = 22;
pub const NETDEV_TAP: netdev_type_t = 21;
pub const NETDEV_SLIPDEV: netdev_type_t = 20;
pub const NETDEV_ETHOS: netdev_type_t = 19;
pub const NETDEV_CC2420: netdev_type_t = 18;
pub const NETDEV_SX1280: netdev_type_t = 17;
pub const NETDEV_SX126X: netdev_type_t = 16;
pub const NETDEV_SOCKET_ZEP: netdev_type_t = 15;
pub const NETDEV_NRF24L01P_NG: netdev_type_t = 14;
pub const NETDEV_ESP_NOW: netdev_type_t = 13;
pub const NETDEV_SAM0_ETH: netdev_type_t = 12;
pub const NETDEV_SX127X: netdev_type_t = 11;
pub const NETDEV_CC110X: netdev_type_t = 10;
pub const NETDEV_STM32_ETH: netdev_type_t = 9;
pub const NETDEV_NRF802154: netdev_type_t = 8;
pub const NETDEV_MRF24J40: netdev_type_t = 7;
pub const NETDEV_KW41ZRF: netdev_type_t = 6;
pub const NETDEV_ENC28J60: netdev_type_t = 5;
pub const NETDEV_DOSE: netdev_type_t = 4;
pub const NETDEV_CC2538: netdev_type_t = 3;
pub const NETDEV_AT86RF2XX: netdev_type_t = 2;
pub const NETDEV_AT86RF215: netdev_type_t = 1;
pub const NETDEV_ANY: netdev_type_t = 0;
#[derive(Copy, Clone)]
#[repr(C, packed)]
pub struct ipv6_ext_frag_t {
pub nh: uint8_t,
pub resv: uint8_t,
pub offset_flags: network_uint16_t,
pub id: network_uint32_t,
}
#[derive(Copy, Clone)]
#[repr(C, packed)]
pub struct ipv6_ext_t {
pub nh: uint8_t,
pub len: uint8_t,
}
#[derive(Copy, Clone)]
#[repr(C, packed)]
pub struct ipv6_hdr_t {
pub v_tc_fl: network_uint32_t,
pub len: network_uint16_t,
pub nh: uint8_t,
pub hl: uint8_t,
pub src: ipv6_addr_t,
pub dst: ipv6_addr_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct netif_t {
pub node: list_node_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct gnrc_netif_ops {
pub init: Option::<unsafe extern "C" fn(*mut gnrc_netif_t) -> libc::c_int>,
pub send: Option::<
unsafe extern "C" fn(*mut gnrc_netif_t, *mut gnrc_pktsnip_t) -> libc::c_int,
>,
pub recv: Option::<unsafe extern "C" fn(*mut gnrc_netif_t) -> *mut gnrc_pktsnip_t>,
pub get: Option::<
unsafe extern "C" fn(*mut gnrc_netif_t, *mut gnrc_netapi_opt_t) -> libc::c_int,
>,
pub set: Option::<
unsafe extern "C" fn(*mut gnrc_netif_t, *const gnrc_netapi_opt_t) -> libc::c_int,
>,
pub msg_handler: Option::<unsafe extern "C" fn(*mut gnrc_netif_t, *mut msg_t) -> ()>,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct gnrc_netif_t {
pub netif: netif_t,
pub ops: *const gnrc_netif_ops_t,
pub dev: *mut netdev_t,
pub mutex: rmutex_t,
pub ipv6: gnrc_netif_ipv6_t,
pub flags: uint32_t,
pub evq: [event_queue_t; 1],
pub event_isr: event_t,
pub l2addr: [uint8_t; 8],
pub l2addr_len: uint8_t,
pub msg_queue: [msg_t; 16],
pub cur_hl: uint8_t,
pub device_type: uint8_t,
pub pid: kernel_pid_t,
}
pub type gnrc_netif_ops_t = gnrc_netif_ops;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct gnrc_netif_hdr_t {
pub src_l2addr_len: uint8_t,
pub dst_l2addr_len: uint8_t,
pub if_pid: kernel_pid_t,
pub flags: uint8_t,
pub lqi: uint8_t,
pub rssi: int16_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct timex_t {
pub seconds: uint32_t,
pub microseconds: uint32_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct gnrc_ipv6_nib_nc_t {
pub ipv6: ipv6_addr_t,
pub l2addr: [uint8_t; 8],
pub info: uint16_t,
pub l2addr_len: uint8_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct gnrc_ipv6_nib_pl_t {
pub pfx: ipv6_addr_t,
pub pfx_len: uint8_t,
pub iface: uint16_t,
pub valid_until: uint32_t,
pub pref_until: uint32_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct sock_ip {
pub reg: gnrc_sock_reg_t,
pub local: sock_ip_ep_t,
pub remote: sock_ip_ep_t,
pub flags: uint16_t,
}
pub type sock_ip_t = sock_ip;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct sock_ip_aux_rx_t {
pub local: sock_ip_ep_t,
pub flags: sock_aux_flags_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct sock_ip_aux_tx_t {
pub local: sock_ip_ep_t,
pub flags: sock_aux_flags_t,
}
pub type sock_tcp_ep_t = _sock_tl_ep;
pub type coap_method_t = libc::c_uchar;
pub const COAP_METHOD_IPATCH: coap_method_t = 7;
pub const COAP_METHOD_PATCH: coap_method_t = 6;
pub const COAP_METHOD_FETCH: coap_method_t = 5;
pub const COAP_METHOD_DELETE: coap_method_t = 4;
pub const COAP_METHOD_PUT: coap_method_t = 3;
pub const COAP_METHOD_POST: coap_method_t = 2;
pub const COAP_METHOD_GET: coap_method_t = 1;
pub type coap_blksize_t = libc::c_uchar;
pub const COAP_BLOCKSIZE_1024: coap_blksize_t = 6;
pub const COAP_BLOCKSIZE_512: coap_blksize_t = 5;
pub const COAP_BLOCKSIZE_256: coap_blksize_t = 4;
pub const COAP_BLOCKSIZE_128: coap_blksize_t = 3;
pub const COAP_BLOCKSIZE_64: coap_blksize_t = 2;
pub const COAP_BLOCKSIZE_32: coap_blksize_t = 1;
pub const COAP_BLOCKSIZE_16: coap_blksize_t = 0;
#[derive(Copy, Clone)]
#[repr(C, packed)]
pub struct coap_hdr_t {
pub ver_t_tkl: uint8_t,
pub code: uint8_t,
pub id: uint16_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct coap_optpos_t {
pub opt_num: uint16_t,
pub offset: uint16_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct coap_pkt_t {
pub hdr: *mut coap_hdr_t,
pub payload: *mut uint8_t,
pub snips: *mut iolist_t,
pub payload_len: uint16_t,
pub options_len: uint16_t,
pub options: [coap_optpos_t; 16],
pub opt_crit: [uint8_t; 2],
pub observe_value: uint32_t,
}
pub type coap_method_flags_t = uint16_t;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct coap_block1_t {
pub offset: size_t,
pub blknum: uint32_t,
pub szx: uint8_t,
pub more: int8_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct coap_block_slicer_t {
pub start: size_t,
pub end: size_t,
pub cur: size_t,
pub opt: *mut uint8_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct sha2xx_context_t {
pub state: [uint32_t; 8],
pub count: [uint32_t; 2],
pub buf: [libc::c_uchar; 64],
}
pub type sha256_context_t = sha2xx_context_t;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct nanocoap_cache_entry_t {
pub node: clist_node_t,
pub cache_key: [uint8_t; 8],
pub response_pkt: coap_pkt_t,
pub response_buf: [uint8_t; 128],
pub response_len: size_t,
pub request_method: uint8_t,
pub truncated: bool,
pub max_age: uint32_t,
}
pub type gcoap_socket_type_t = libc::c_uchar;
pub const GCOAP_SOCKET_TYPE_DTLS: gcoap_socket_type_t = 2;
pub const GCOAP_SOCKET_TYPE_UDP: gcoap_socket_type_t = 1;
pub const GCOAP_SOCKET_TYPE_UNDEF: gcoap_socket_type_t = 0;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct gcoap_socket_t {
pub type_0: gcoap_socket_type_t,
pub socket: C2RustUnnamed_8,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub union C2RustUnnamed_8 {
pub udp: *mut sock_udp_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct gcoap_request_memo {
pub state: libc::c_uint,
pub send_limit: libc::c_int,
pub msg: C2RustUnnamed_9,
pub remote_ep: sock_udp_ep_t,
pub resp_handler: gcoap_resp_handler_t,
pub context: *mut libc::c_void,
pub resp_evt_tmout: event_timeout_t,
pub resp_tmout_cb: event_callback_t,
pub socket: gcoap_socket_t,
}
pub type gcoap_resp_handler_t = Option::<
unsafe extern "C" fn(
*const gcoap_request_memo_t,
*mut coap_pkt_t,
*const sock_udp_ep_t,
) -> (),
>;
pub type gcoap_request_memo_t = gcoap_request_memo;
#[derive(Copy, Clone)]
#[repr(C)]
pub union C2RustUnnamed_9 {
pub hdr_buf: [uint8_t; 12],
pub data: gcoap_resend_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct gcoap_resend_t {
pub pdu_buf: *mut uint8_t,
pub pdu_len: size_t,
}
pub type FILE = __FILE;
pub type sha224_context_t = sha2xx_context_t;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct sha512_common_context_t {
pub state: [uint64_t; 8],
pub count: [uint64_t; 2],
pub buf: [libc::c_uchar; 128],
}
pub type sha512_context_t = sha512_common_context_t;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct nanocoap_sock_t {
pub udp: sock_udp_t,
pub msg_id: uint16_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct coap_block_request_t {
pub sock: *mut nanocoap_sock_t,
pub path: *const libc::c_char,
pub blknum: uint32_t,
pub method: coap_method_t,
pub blksize: uint8_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct tsrb {
pub buf: *mut uint8_t,
pub size: libc::c_uint,
pub reads: libc::c_uint,
pub writes: libc::c_uint,
}
pub type tsrb_t = tsrb;
pub type shell_command_handler_t = Option::<
unsafe extern "C" fn(libc::c_int, *mut *mut libc::c_char) -> libc::c_int,
>;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct shell_command_t {
pub name: *const libc::c_char,
pub desc: *const libc::c_char,
pub handler: shell_command_handler_t,
}
pub type cose_hdr_type_t = libc::c_uchar;
pub const COSE_HDR_TYPE_CBOR: cose_hdr_type_t = 4;
pub const COSE_HDR_TYPE_BSTR: cose_hdr_type_t = 3;
pub const COSE_HDR_TYPE_TSTR: cose_hdr_type_t = 2;
pub const COSE_HDR_TYPE_INT: cose_hdr_type_t = 1;
pub const COSE_HDR_TYPE_UNDEF: cose_hdr_type_t = 0;
pub type cose_kty_t = libc::c_uchar;
pub const COSE_KTY_HSSLMS: cose_kty_t = 5;
pub const COSE_KTY_SYMM: cose_kty_t = 4;
pub const COSE_KTY_RSA: cose_kty_t = 3;
pub const COSE_KTY_EC2: cose_kty_t = 2;
pub const COSE_KTY_OCTET: cose_kty_t = 1;
pub type cose_curve_t = libc::c_uchar;
pub const COSE_EC_CURVE_ED448: cose_curve_t = 7;
pub const COSE_EC_CURVE_ED25519: cose_curve_t = 6;
pub const COSE_EC_CURVE_X448: cose_curve_t = 5;
pub const COSE_EC_CURVE_X25519: cose_curve_t = 4;
pub const COSE_EC_CURVE_P521: cose_curve_t = 3;
pub const COSE_EC_CURVE_P384: cose_curve_t = 2;
pub const COSE_EC_CURVE_P256: cose_curve_t = 1;
pub const COSE_EC_NONE: cose_curve_t = 0;
pub type cose_algo_t = libc::c_schar;
pub const COSE_ALGO_AESCCM_64_128_256: cose_algo_t = 33;
pub const COSE_ALGO_AESCCM_64_128_128: cose_algo_t = 32;
pub const COSE_ALGO_AESCCM_16_128_256: cose_algo_t = 31;
pub const COSE_ALGO_AESCCM_16_128_128: cose_algo_t = 30;
pub const COSE_ALGO_CHACHA20POLY1305: cose_algo_t = 24;
pub const COSE_ALGO_AESCCM_64_64_256: cose_algo_t = 13;
pub const COSE_ALGO_AESCCM_64_64_128: cose_algo_t = 12;
pub const COSE_ALGO_AESCCM_16_64_256: cose_algo_t = 11;
pub const COSE_ALGO_AESCCM_16_64_128: cose_algo_t = 10;
pub const COSE_ALGO_HMAC256: cose_algo_t = 5;
pub const COSE_ALGO_A256GCM: cose_algo_t = 3;
pub const COSE_ALGO_A192GCM: cose_algo_t = 2;
pub const COSE_ALGO_A128GCM: cose_algo_t = 1;
pub const COSE_ALGO_DIRECT: cose_algo_t = -6;
pub const COSE_ALGO_ES256: cose_algo_t = -7;
pub const COSE_ALGO_EDDSA: cose_algo_t = -8;
pub const COSE_ALGO_ES384: cose_algo_t = -35;
pub const COSE_ALGO_ES512: cose_algo_t = -36;
pub const COSE_ALGO_HSSLMS: cose_algo_t = -46;
pub const COSE_ALGO_NONE: cose_algo_t = 0;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct nanocbor_value {
pub cur: *const uint8_t,
pub end: *const uint8_t,
pub remaining: uint64_t,
pub flags: uint8_t,
}
pub type nanocbor_value_t = nanocbor_value;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct cose_hdr {
pub next: *mut cose_hdr,
pub key: int32_t,
pub len: size_t,
pub v: C2RustUnnamed_10,
pub type_0: cose_hdr_type_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub union C2RustUnnamed_10 {
pub value: int32_t,
pub data: *const uint8_t,
pub str_0: *const libc::c_char,
pub cbor: *const uint8_t,
}
pub type cose_hdr_t = cose_hdr;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct cose_headers_t {
pub prot: *mut cose_hdr_t,
pub unprot: *mut cose_hdr_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct cose_key {
pub kty: cose_kty_t,
pub algo: cose_algo_t,
pub crv: cose_curve_t,
pub kid: *mut uint8_t,
pub kid_len: size_t,
pub x: *mut uint8_t,
pub y: *mut uint8_t,
pub d: *mut uint8_t,
}
pub type cose_key_t = cose_key;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct cose_signature {
pub next: *mut cose_signature,
pub hdrs: cose_headers_t,
pub signature: *const uint8_t,
pub signature_len: size_t,
pub signer: *const cose_key_t,
}
pub type cose_signature_t = cose_signature;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct cose_signature_dec {
pub buf: *const uint8_t,
pub len: size_t,
}
pub type cose_signature_dec_t = cose_signature_dec;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct cose_sign {
pub hdrs: cose_headers_t,
pub signatures: *mut cose_signature_t,
pub payload: *const libc::c_void,
pub payload_len: size_t,
pub ext_aad: *const libc::c_void,
pub ext_aad_len: size_t,
pub flags: uint16_t,
}
pub type cose_sign_enc_t = cose_sign;
#[derive(Copy, Clone)]
#[repr(C, packed)]
pub struct uuid_t {
pub time_low: network_uint32_t,
pub time_mid: network_uint16_t,
pub time_hi: network_uint16_t,
pub clk_seq_hi_res: uint8_t,
pub clk_seq_low: uint8_t,
pub node: [uint8_t; 6],
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct suit_param_ref_t {
pub offset: uint16_t,
}
pub type suit_storage_ref_t = suit_storage;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct suit_component_t {
pub storage_backend: *mut suit_storage_ref_t,
pub state: uint16_t,
pub identifier: suit_param_ref_t,
pub param_vendor_id: suit_param_ref_t,
pub param_class_id: suit_param_ref_t,
pub param_digest: suit_param_ref_t,
pub param_uri: suit_param_ref_t,
pub param_size: suit_param_ref_t,
pub param_component_offset: suit_param_ref_t,
}
pub const __builtin_arm_get_fpscr: unsafe extern "C" fn() -> libc::c_int = __masked_builtin_arm_get_fpscr;
pub const __builtin_arm_set_fpscr: unsafe extern "C" fn(libc::c_int) -> () = __masked_builtin_arm_set_fpscr;
#[inline]
unsafe extern "C" fn __masked_builtin_arm_get_fpscr() -> libc::c_int {
return missing_implementation_for_fpscr_in_c2rust_see_issue_345;
}
#[inline]
unsafe extern "C" fn __masked_builtin_arm_set_fpscr(mut fpscr: libc::c_int) {
missing_implementation_for_fpscr_in_c2rust_see_issue_345 = fpscr;
}
pub const NULL: libc::c_int = 0 as libc::c_int;
pub const NULL_0: libc::c_int = 0 as libc::c_int;
pub const NULL_1: libc::c_int = 0 as libc::c_int;
pub const NULL_2: libc::c_int = 0 as libc::c_int;
#[inline]
pub unsafe fn may_be_zero(mut n: libc::c_uint) -> libc::c_uint {
return n;
}
#[inline]
pub unsafe fn list_add(
mut node: *mut list_node_t,
mut new_node: *mut list_node_t,
) {
(*new_node).next = (*node).next;
(*node).next = new_node;
}
#[inline]
pub unsafe fn list_remove_head(mut list: *mut list_node_t) -> *mut list_node_t {
let mut head: *mut list_node_t = (*list).next;
if !head.is_null() {
(*list).next = (*head).next;
}
return head;
}
#[inline]
pub unsafe fn list_remove(
mut list: *mut list_node_t,
mut node: *mut list_node_t,
) -> *mut list_node_t {
while !((*list).next).is_null() {
if (*list).next == node {
(*list).next = (*node).next;
return node;
}
list = (*list).next;
}
return (*list).next;
}
#[inline]
pub unsafe fn clist_is_empty(mut list: *const clist_node_t) -> bool {
return ((*list).next).is_null();
}
#[inline]
pub unsafe fn clist_rpush(
mut list: *mut clist_node_t,
mut new_node: *mut clist_node_t,
) {
if !((*list).next).is_null() {
(*new_node).next = (*(*list).next).next;
(*(*list).next).next = new_node;
} else {
(*new_node).next = new_node;
}
(*list).next = new_node;
}
#[inline]
pub unsafe fn clist_lpush(
mut list: *mut clist_node_t,
mut new_node: *mut clist_node_t,
) {
if !((*list).next).is_null() {
(*new_node).next = (*(*list).next).next;
(*(*list).next).next = new_node;
} else {
(*new_node).next = new_node;
(*list).next = new_node;
};
}
#[inline]
pub unsafe fn clist_lpop(mut list: *mut clist_node_t) -> *mut clist_node_t {
if !((*list).next).is_null() {
let mut first: *mut clist_node_t = (*(*list).next).next;
if (*list).next == first {
(*list).next = NULL as *mut list_node;
} else {
(*(*list).next).next = (*first).next;
}
return first;
} else {
return NULL as *mut clist_node_t
};
}
#[inline]
pub unsafe fn clist_lpoprpush(mut list: *mut clist_node_t) {
if !((*list).next).is_null() {
(*list).next = (*(*list).next).next;
}
}
#[inline]
pub unsafe fn clist_lpeek(mut list: *const clist_node_t) -> *mut clist_node_t {
if !((*list).next).is_null() {
return (*(*list).next).next;
}
return NULL as *mut clist_node_t;
}
#[inline]
pub unsafe fn clist_rpeek(mut list: *const clist_node_t) -> *mut clist_node_t {
return (*list).next;
}
#[inline]
pub unsafe fn clist_rpop(mut list: *mut clist_node_t) -> *mut clist_node_t {
if !((*list).next).is_null() {
let mut last: *mut list_node_t = (*list).next;
while (*(*list).next).next != last {
clist_lpoprpush(list);
}
return clist_lpop(list);
} else {
return NULL as *mut clist_node_t
};
}
#[inline]
pub unsafe fn clist_find_before(
mut list: *const clist_node_t,
mut node: *const clist_node_t,
) -> *mut clist_node_t {
let mut pos: *mut clist_node_t = (*list).next;
if pos.is_null() {
return NULL as *mut clist_node_t;
}
loop {
pos = (*pos).next;
if (*pos).next == node as *mut list_node {
return pos;
}
if !(pos != (*list).next) {
break;
}
}
return NULL as *mut clist_node_t;
}
#[inline]
pub unsafe fn clist_find(
mut list: *const clist_node_t,
mut node: *const clist_node_t,
) -> *mut clist_node_t {
let mut tmp: *mut clist_node_t = clist_find_before(list, node);
if !tmp.is_null() { return (*tmp).next } else { return NULL as *mut clist_node_t };
}
#[inline]
pub unsafe fn clist_remove(
mut list: *mut clist_node_t,
mut node: *mut clist_node_t,
) -> *mut clist_node_t {
if !((*list).next).is_null() {
if (*(*list).next).next == node {
return clist_lpop(list)
} else {
let mut tmp: *mut clist_node_t = clist_find_before(list, node);
if !tmp.is_null() {
(*tmp).next = (*(*tmp).next).next;
if node == (*list).next {
(*list).next = tmp;
}
return node;
}
}
}
return NULL as *mut clist_node_t;
}
#[inline]
pub unsafe fn clist_foreach(
mut list: *mut clist_node_t,
mut func: Option::<
unsafe extern "C" fn(*mut clist_node_t, *mut libc::c_void) -> libc::c_int,
>,
mut arg: *mut libc::c_void,
) -> *mut clist_node_t {
let mut node: *mut clist_node_t = (*list).next;
if !node.is_null() {
loop {
node = (*node).next;
if func.expect("non-null function pointer")(node, arg) != 0 {
return node;
}
if !(node != (*list).next) {
break;
}
}
}
return NULL as *mut clist_node_t;
}
#[inline]
pub unsafe fn clist_sort(mut list: *mut clist_node_t, mut cmp: clist_cmp_func_t) {
if !((*list).next).is_null() {
(*list).next = _clist_sort((*(*list).next).next, cmp);
}
}
#[inline]
pub unsafe fn clist_count(mut list: *mut clist_node_t) -> size_t {
let mut node: *mut clist_node_t = (*list).next;
let mut cnt: size_t = 0 as libc::c_int as size_t;
if !node.is_null() {
loop {
node = (*node).next;
cnt = cnt.wrapping_add(1);
cnt;
if !(node != (*list).next) {
break;
}
}
}
return cnt;
}
#[inline]
pub unsafe fn clist_exactly_one(mut list: *mut clist_node_t) -> bool {
return !clist_is_empty(list) && (*list).next == (*(*list).next).next;
}
#[inline]
pub unsafe fn clist_more_than_one(mut list: *mut clist_node_t) -> bool {
return !clist_is_empty(list) && (*list).next != (*(*list).next).next;
}
#[inline]
pub unsafe fn cib_init(mut cib: *mut cib_t, mut size: libc::c_uint) {
if (size & size.wrapping_sub(1 as libc::c_int as libc::c_uint) == 0) as libc::c_int
as uintptr_t as libc::c_long != 0
{} else {
_assert_panic();
};
let mut c: cib_t = {
let mut init = cib_t {
read_count: 0 as libc::c_int as libc::c_uint,
write_count: 0 as libc::c_int as libc::c_uint,
mask: size.wrapping_sub(1 as libc::c_int as libc::c_uint),
};
init
};
*cib = c;
}
#[inline]
pub unsafe fn cib_size(mut cib: *const cib_t) -> libc::c_uint {
return ((*cib).mask).wrapping_add(1 as libc::c_int as libc::c_uint);
}
#[inline]
pub unsafe fn cib_avail(mut cib: *const cib_t) -> libc::c_uint {
return ((*cib).write_count).wrapping_sub((*cib).read_count);
}
#[inline]
pub unsafe fn cib_full(mut cib: *const cib_t) -> libc::c_uint {
return (cib_avail(cib) as libc::c_int > (*cib).mask as libc::c_int) as libc::c_int
as libc::c_uint;
}
#[inline]
pub unsafe fn cib_get(mut cib: *mut cib_t) -> libc::c_int {
if cib_avail(cib) != 0 {
let fresh0 = (*cib).read_count;
(*cib).read_count = ((*cib).read_count).wrapping_add(1);
return (fresh0 & (*cib).mask) as libc::c_int;
}
return -(1 as libc::c_int);
}
#[inline]
pub unsafe fn cib_peek_at_unsafe(
mut cib: *mut cib_t,
mut offset: libc::c_uint,
) -> libc::c_int {
return (((*cib).read_count).wrapping_add(offset) & (*cib).mask) as libc::c_int;
}
#[inline]
pub unsafe fn cib_peek_at(
mut cib: *mut cib_t,
mut offset: libc::c_uint,
) -> libc::c_int {
if offset < cib_avail(cib) {
return cib_peek_at_unsafe(cib, offset);
}
return -(1 as libc::c_int);
}
#[inline]
pub unsafe fn cib_peek_unsafe(mut cib: *mut cib_t) -> libc::c_int {
return cib_peek_at_unsafe(cib, 0 as libc::c_int as libc::c_uint);
}
#[inline]
pub unsafe fn cib_peek(mut cib: *mut cib_t) -> libc::c_int {
return cib_peek_at(cib, 0 as libc::c_int as libc::c_uint);
}
#[inline]
pub unsafe fn cib_get_unsafe(mut cib: *mut cib_t) -> libc::c_int {
let fresh1 = (*cib).read_count;
(*cib).read_count = ((*cib).read_count).wrapping_add(1);
return (fresh1 & (*cib).mask) as libc::c_int;
}
#[inline]
pub unsafe fn cib_put(mut cib: *mut cib_t) -> libc::c_int {
let mut avail: libc::c_uint = cib_avail(cib);
if avail as libc::c_int <= (*cib).mask as libc::c_int {
let fresh2 = (*cib).write_count;
(*cib).write_count = ((*cib).write_count).wrapping_add(1);
return (fresh2 & (*cib).mask) as libc::c_int;
}
return -(1 as libc::c_int);
}
#[inline]
pub unsafe fn cib_put_unsafe(mut cib: *mut cib_t) -> libc::c_int {
let fresh3 = (*cib).write_count;
(*cib).write_count = ((*cib).write_count).wrapping_add(1);
return (fresh3 & (*cib).mask) as libc::c_int;
}
#[inline]
pub unsafe fn pid_is_valid(mut pid: kernel_pid_t) -> libc::c_int {
return (KERNEL_PID_FIRST <= pid as libc::c_int
&& pid as libc::c_int <= KERNEL_PID_LAST) as libc::c_int;
}
pub const MAXTHREADS: libc::c_int = 32 as libc::c_int;
pub const KERNEL_PID_UNDEF: libc::c_int = 0 as libc::c_int;
pub const KERNEL_PID_FIRST: libc::c_int = KERNEL_PID_UNDEF + 1 as libc::c_int;
pub const KERNEL_PID_LAST: libc::c_int = KERNEL_PID_FIRST + MAXTHREADS
- 1 as libc::c_int;
#[inline]
pub unsafe fn sched_runq_advance(mut prio: uint8_t) {
clist_lpoprpush(&mut *sched_runqueues.as_mut_ptr().offset(prio as isize));
}
#[inline]
pub unsafe fn sched_runq_is_empty(mut prio: uint8_t) -> libc::c_int {
return clist_is_empty(&mut *sched_runqueues.as_mut_ptr().offset(prio as isize))
as libc::c_int;
}
#[inline]
pub unsafe fn sched_runq_exactly_one(mut prio: uint8_t) -> libc::c_int {
return clist_exactly_one(&mut *sched_runqueues.as_mut_ptr().offset(prio as isize))
as libc::c_int;
}
#[inline]
pub unsafe fn sched_runq_more_than_one(mut prio: uint8_t) -> libc::c_int {
return clist_more_than_one(&mut *sched_runqueues.as_mut_ptr().offset(prio as isize))
as libc::c_int;
}
#[inline]
pub unsafe fn msg_sent_by_int(mut m: *const msg_t) -> libc::c_int {
return ((*m).sender_pid as libc::c_int == KERNEL_PID_ISR) as libc::c_int;
}
pub const KERNEL_PID_ISR: libc::c_int = KERNEL_PID_LAST + 1 as libc::c_int;
#[inline(always)]
pub unsafe fn __cmsis_start() -> ! {
extern "C" {
#[link_name = "_start"]
fn _start_0() -> !;
}
extern "C" {
static __copy_table_start__: __copy_table_t;
}
extern "C" {
static __copy_table_end__: __copy_table_t;
}
extern "C" {
static __zero_table_start__: __zero_table_t;
}
extern "C" {
static __zero_table_end__: __zero_table_t;
}
let mut pTable: *const __copy_table_t = &__copy_table_start__;
while pTable < &__copy_table_end__ as *const __copy_table_t {
let mut i: uint32_t = 0 as libc::c_uint;
while i < (*pTable).wlen {
*((*pTable).dest).offset(i as isize) = *((*pTable).src).offset(i as isize);
i = i.wrapping_add(1);
i;
}
pTable = pTable.offset(1);
pTable;
}
let mut pTable_0: *const __zero_table_t = &__zero_table_start__;
while pTable_0 < &__zero_table_end__ as *const __zero_table_t {
let mut i_0: uint32_t = 0 as libc::c_uint;
while i_0 < (*pTable_0).wlen {
*((*pTable_0).dest).offset(i_0 as isize) = 0 as libc::c_uint;
i_0 = i_0.wrapping_add(1);
i_0;
}
pTable_0 = pTable_0.offset(1);
pTable_0;
}
_start_0();
}
#[inline(always)]
pub unsafe fn __ISB() {
asm!("isb 0xF", options(preserves_flags));
}
#[inline(always)]
pub unsafe fn __DSB() {
asm!("dsb 0xF", options(preserves_flags));
}
#[inline(always)]
pub unsafe fn __DMB() {
asm!("dmb 0xF", options(preserves_flags));
}
#[inline(always)]
pub unsafe fn __REV(mut value: uint32_t) -> uint32_t {
let mut result: uint32_t = 0;
asm!(
"rev {0}, {1}", lateout(reg) result, inlateout(reg) value => _,
options(preserves_flags, pure, readonly)
);
return result;
}
#[inline(always)]
pub unsafe fn __REV16(mut value: uint32_t) -> uint32_t {
let mut result: uint32_t = 0;
asm!(
"rev16 {0}, {1}", lateout(reg) result, inlateout(reg) value => _,
options(preserves_flags, pure, readonly)
);
return result;
}
#[inline(always)]
pub unsafe fn __REVSH(mut value: int16_t) -> int16_t {
let mut result: int16_t = 0;
asm!(
"revsh {0}, {1}", lateout(reg) result, inlateout(reg) value => _,
options(preserves_flags, pure, readonly)
);
return result;
}
#[inline(always)]
pub unsafe fn __ROR(mut op1: uint32_t, mut op2: uint32_t) -> uint32_t {
op2 = (op2 as libc::c_uint).wrapping_rem(32 as libc::c_uint) as uint32_t as uint32_t;
if op2 == 0 as libc::c_uint {
return op1;
}
return op1 >> op2 | op1 << (32 as libc::c_uint).wrapping_sub(op2);
}
#[inline(always)]
pub unsafe fn __RBIT(mut value: uint32_t) -> uint32_t {
let mut result: uint32_t = 0;
asm!(
"rbit {0}, {1}", lateout(reg) result, inlateout(reg) value => _,
options(preserves_flags, pure, readonly)
);
return result;
}
#[inline(always)]
pub unsafe fn __CLZ(mut value: uint32_t) -> uint8_t {
if value == 0 as libc::c_uint {
return 32 as libc::c_uint as uint8_t;
}
return value.leading_zeros() as i32 as uint8_t;
}
#[inline(always)]
pub unsafe fn __LDREXB(mut addr: *mut uint8_t) -> uint8_t {
let mut result: uint32_t = 0;
asm!(
"ldrexb {0}, [{1}]", lateout(reg) result, inlateout(reg) addr => _,
options(preserves_flags)
);
return result as uint8_t;
}
#[inline(always)]
pub unsafe fn __LDREXH(mut addr: *mut uint16_t) -> uint16_t {
let mut result: uint32_t = 0;
asm!(
"ldrexh {0}, [{1}]", lateout(reg) result, inlateout(reg) addr => _,
options(preserves_flags)
);
return result as uint16_t;
}
#[inline(always)]
pub unsafe fn __LDREXW(mut addr: *mut uint32_t) -> uint32_t {
let mut result: uint32_t = 0;
asm!(
"ldrex {0}, [{1}]", lateout(reg) result, in (reg) & * addr,
options(preserves_flags)
);
return result;
}
#[inline(always)]
pub unsafe fn __STREXB(mut value: uint8_t, mut addr: *mut uint8_t) -> uint32_t {
let mut result: uint32_t = 0;
asm!(
"strexb {0}, {2}, [{1}]", out(reg) result, in (reg) & mut * addr, inlateout(reg)
value as uint32_t => _, options(preserves_flags)
);
return result;
}
#[inline(always)]
pub unsafe fn __STREXH(mut value: uint16_t, mut addr: *mut uint16_t) -> uint32_t {
let mut result: uint32_t = 0;
asm!(
"strexh {0}, {2}, [{1}]", out(reg) result, in (reg) & mut * addr, inlateout(reg)
value as uint32_t => _, options(preserves_flags)
);
return result;
}
#[inline(always)]
pub unsafe fn __STREXW(mut value: uint32_t, mut addr: *mut uint32_t) -> uint32_t {
let mut result: uint32_t = 0;
asm!(
"strex {0}, {2}, [{1}]", out(reg) result, in (reg) & mut * addr, inlateout(reg)
value => _, options(preserves_flags)
);
return result;
}
#[inline(always)]
pub unsafe fn __CLREX() {
asm!("clrex", options(preserves_flags));
}
#[inline(always)]
pub unsafe fn __RRX(mut value: uint32_t) -> uint32_t {
let mut result: uint32_t = 0;
asm!(
"rrx {0}, {1}", lateout(reg) result, inlateout(reg) value => _,
options(preserves_flags)
);
return result;
}
#[inline(always)]
pub unsafe fn __LDRBT(mut ptr: *mut uint8_t) -> uint8_t {
let mut result: uint32_t = 0;
asm!(
"ldrbt {0}, [{1}]", lateout(reg) result, inlateout(reg) ptr => _,
options(preserves_flags)
);
return result as uint8_t;
}
#[inline(always)]
pub unsafe fn __LDRHT(mut ptr: *mut uint16_t) -> uint16_t {
let mut result: uint32_t = 0;
asm!(
"ldrht {0}, [{1}]", lateout(reg) result, inlateout(reg) ptr => _,
options(preserves_flags)
);
return result as uint16_t;
}
#[inline(always)]
pub unsafe fn __LDRT(mut ptr: *mut uint32_t) -> uint32_t {
let mut result: uint32_t = 0;
asm!(
"ldrt {0}, [{1}]", lateout(reg) result, in (reg) & * ptr,
options(preserves_flags)
);
return result;
}
#[inline(always)]
pub unsafe fn __STRBT(mut value: uint8_t, mut ptr: *mut uint8_t) {
asm!(
"strbt {1}, [{0}]", in (reg) & mut * ptr, inlateout(reg) value as uint32_t => _,
options(preserves_flags)
);
}
#[inline(always)]
pub unsafe fn __STRHT(mut value: uint16_t, mut ptr: *mut uint16_t) {
asm!(
"strht {1}, [{0}]", in (reg) & mut * ptr, inlateout(reg) value as uint32_t => _,
options(preserves_flags)
);
}
#[inline(always)]
pub unsafe fn __STRT(mut value: uint32_t, mut ptr: *mut uint32_t) {
asm!(
"strt {1}, [{0}]", in (reg) & mut * ptr, inlateout(reg) value => _,
options(preserves_flags)
);
}
#[inline(always)]
pub unsafe fn __enable_irq() {
asm!("cpsie i", options(preserves_flags));
}
#[inline(always)]
pub unsafe fn __disable_irq() {
asm!("cpsid i", options(preserves_flags));
}
#[inline(always)]
pub unsafe fn __get_CONTROL() -> uint32_t {
let mut result: uint32_t = 0;
asm!("MRS {0}, control", lateout(reg) result, options(preserves_flags));
return result;
}
#[inline(always)]
pub unsafe fn __set_CONTROL(mut control: uint32_t) {
asm!("MSR control, {0}", inlateout(reg) control => _, options(preserves_flags));
__ISB();
}
#[inline(always)]
pub unsafe fn __get_IPSR() -> uint32_t {
let mut result: uint32_t = 0;
asm!("MRS {0}, ipsr", lateout(reg) result, options(preserves_flags));
return result;
}
#[inline(always)]
pub unsafe fn __get_APSR() -> uint32_t {
let mut result: uint32_t = 0;
asm!("MRS {0}, apsr", lateout(reg) result, options(preserves_flags));
return result;
}
#[inline(always)]
pub unsafe fn __get_xPSR() -> uint32_t {
let mut result: uint32_t = 0;
asm!("MRS {0}, xpsr", lateout(reg) result, options(preserves_flags));
return result;
}
#[inline(always)]
pub unsafe fn __get_PSP() -> uint32_t {
let mut result: uint32_t = 0;
asm!("MRS {0}, psp", lateout(reg) result, options(preserves_flags));
return result;
}
#[inline(always)]
pub unsafe fn __set_PSP(mut topOfProcStack: uint32_t) {
asm!("MSR psp, {0}", inlateout(reg) topOfProcStack => _, options(preserves_flags));
}
#[inline(always)]
pub unsafe fn __get_MSP() -> uint32_t {
let mut result: uint32_t = 0;
asm!("MRS {0}, msp", lateout(reg) result, options(preserves_flags));
return result;
}
#[inline(always)]
pub unsafe fn __set_MSP(mut topOfMainStack: uint32_t) {
asm!("MSR msp, {0}", inlateout(reg) topOfMainStack => _, options(preserves_flags));
}
#[inline(always)]
pub unsafe fn __get_PRIMASK() -> uint32_t {
let mut result: uint32_t = 0;
asm!("MRS {0}, primask", lateout(reg) result, options(preserves_flags));
return result;
}
#[inline(always)]
pub unsafe fn __set_PRIMASK(mut priMask: uint32_t) {
asm!("MSR primask, {0}", inlateout(reg) priMask => _, options(preserves_flags));
}
#[inline(always)]
pub unsafe fn __enable_fault_irq() {
asm!("cpsie f", options(preserves_flags));
}
#[inline(always)]
pub unsafe fn __disable_fault_irq() {
asm!("cpsid f", options(preserves_flags));
}
#[inline(always)]
pub unsafe fn __get_BASEPRI() -> uint32_t {
let mut result: uint32_t = 0;
asm!("MRS {0}, basepri", lateout(reg) result, options(preserves_flags));
return result;
}
#[inline(always)]
pub unsafe fn __set_BASEPRI(mut basePri: uint32_t) {
asm!("MSR basepri, {0}", inlateout(reg) basePri => _, options(preserves_flags));
}
#[inline(always)]
pub unsafe fn __set_BASEPRI_MAX(mut basePri: uint32_t) {
asm!("MSR basepri_max, {0}", inlateout(reg) basePri => _, options(preserves_flags));
}
#[inline(always)]
pub unsafe fn __get_FAULTMASK() -> uint32_t {
let mut result: uint32_t = 0;
asm!("MRS {0}, faultmask", lateout(reg) result, options(preserves_flags));
return result;
}
#[inline(always)]
pub unsafe fn __set_FAULTMASK(mut faultMask: uint32_t) {
asm!("MSR faultmask, {0}", inlateout(reg) faultMask => _, options(preserves_flags));
}
#[inline(always)]
pub unsafe fn __get_FPSCR() -> uint32_t {
return __masked_builtin_arm_get_fpscr() as uint32_t;
}
#[inline(always)]
pub unsafe fn __set_FPSCR(mut fpscr: uint32_t) {
__masked_builtin_arm_set_fpscr(fpscr as libc::c_int);
}
#[inline(always)]
pub unsafe fn __SADD8(mut op1: uint32_t, mut op2: uint32_t) -> uint32_t {
let mut result: uint32_t = 0;
asm!(
"sadd8 {0}, {1}, {2}", lateout(reg) result, inlateout(reg) op1 => _,
inlateout(reg) op2 => _, options(preserves_flags)
);
return result;
}
#[inline(always)]
pub unsafe fn __QADD8(mut op1: uint32_t, mut op2: uint32_t) -> uint32_t {
let mut result: uint32_t = 0;
asm!(
"qadd8 {0}, {1}, {2}", lateout(reg) result, inlateout(reg) op1 => _,
inlateout(reg) op2 => _, options(preserves_flags, pure, readonly)
);
return result;
}
#[inline(always)]
pub unsafe fn __SHADD8(mut op1: uint32_t, mut op2: uint32_t) -> uint32_t {
let mut result: uint32_t = 0;
asm!(
"shadd8 {0}, {1}, {2}", lateout(reg) result, inlateout(reg) op1 => _,
inlateout(reg) op2 => _, options(preserves_flags, pure, readonly)
);
return result;
}
#[inline(always)]
pub unsafe fn __UADD8(mut op1: uint32_t, mut op2: uint32_t) -> uint32_t {
let mut result: uint32_t = 0;
asm!(
"uadd8 {0}, {1}, {2}", lateout(reg) result, inlateout(reg) op1 => _,
inlateout(reg) op2 => _, options(preserves_flags)
);
return result;
}
#[inline(always)]
pub unsafe fn __UQADD8(mut op1: uint32_t, mut op2: uint32_t) -> uint32_t {
let mut result: uint32_t = 0;
asm!(
"uqadd8 {0}, {1}, {2}", lateout(reg) result, inlateout(reg) op1 => _,
inlateout(reg) op2 => _, options(preserves_flags, pure, readonly)
);
return result;
}
#[inline(always)]
pub unsafe fn __UHADD8(mut op1: uint32_t, mut op2: uint32_t) -> uint32_t {
let mut result: uint32_t = 0;
asm!(
"uhadd8 {0}, {1}, {2}", lateout(reg) result, inlateout(reg) op1 => _,
inlateout(reg) op2 => _, options(preserves_flags, pure, readonly)
);
return result;
}
#[inline(always)]
pub unsafe fn __SSUB8(mut op1: uint32_t, mut op2: uint32_t) -> uint32_t {
let mut result: uint32_t = 0;
asm!(
"ssub8 {0}, {1}, {2}", lateout(reg) result, inlateout(reg) op1 => _,
inlateout(reg) op2 => _, options(preserves_flags)
);
return result;
}
#[inline(always)]
pub unsafe fn __QSUB8(mut op1: uint32_t, mut op2: uint32_t) -> uint32_t {
let mut result: uint32_t = 0;
asm!(
"qsub8 {0}, {1}, {2}", lateout(reg) result, inlateout(reg) op1 => _,
inlateout(reg) op2 => _, options(preserves_flags, pure, readonly)
);
return result;
}
#[inline(always)]
pub unsafe fn __SHSUB8(mut op1: uint32_t, mut op2: uint32_t) -> uint32_t {
let mut result: uint32_t = 0;
asm!(
"shsub8 {0}, {1}, {2}", lateout(reg) result, inlateout(reg) op1 => _,
inlateout(reg) op2 => _, options(preserves_flags, pure, readonly)
);
return result;
}
#[inline(always)]
pub unsafe fn __USUB8(mut op1: uint32_t, mut op2: uint32_t) -> uint32_t {
let mut result: uint32_t = 0;
asm!(
"usub8 {0}, {1}, {2}", lateout(reg) result, inlateout(reg) op1 => _,
inlateout(reg) op2 => _, options(preserves_flags)
);
return result;
}
#[inline(always)]
pub unsafe fn __UQSUB8(mut op1: uint32_t, mut op2: uint32_t) -> uint32_t {
let mut result: uint32_t = 0;
asm!(
"uqsub8 {0}, {1}, {2}", lateout(reg) result, inlateout(reg) op1 => _,
inlateout(reg) op2 => _, options(preserves_flags, pure, readonly)
);
return result;
}
#[inline(always)]
pub unsafe fn __UHSUB8(mut op1: uint32_t, mut op2: uint32_t) -> uint32_t {
let mut result: uint32_t = 0;
asm!(
"uhsub8 {0}, {1}, {2}", lateout(reg) result, inlateout(reg) op1 => _,
inlateout(reg) op2 => _, options(preserves_flags, pure, readonly)
);
return result;
}
#[inline(always)]
pub unsafe fn __SADD16(mut op1: uint32_t, mut op2: uint32_t) -> uint32_t {
let mut result: uint32_t = 0;
asm!(
"sadd16 {0}, {1}, {2}", lateout(reg) result, inlateout(reg) op1 => _,
inlateout(reg) op2 => _, options(preserves_flags)
);
return result;
}
#[inline(always)]
pub unsafe fn __QADD16(mut op1: uint32_t, mut op2: uint32_t) -> uint32_t {
let mut result: uint32_t = 0;
asm!(
"qadd16 {0}, {1}, {2}", lateout(reg) result, inlateout(reg) op1 => _,
inlateout(reg) op2 => _, options(preserves_flags, pure, readonly)
);
return result;
}
#[inline(always)]
pub unsafe fn __SHADD16(mut op1: uint32_t, mut op2: uint32_t) -> uint32_t {
let mut result: uint32_t = 0;
asm!(
"shadd16 {0}, {1}, {2}", lateout(reg) result, inlateout(reg) op1 => _,
inlateout(reg) op2 => _, options(preserves_flags, pure, readonly)
);
return result;
}
#[inline(always)]
pub unsafe fn __UADD16(mut op1: uint32_t, mut op2: uint32_t) -> uint32_t {
let mut result: uint32_t = 0;
asm!(
"uadd16 {0}, {1}, {2}", lateout(reg) result, inlateout(reg) op1 => _,
inlateout(reg) op2 => _, options(preserves_flags)
);
return result;
}
#[inline(always)]
pub unsafe fn __UQADD16(mut op1: uint32_t, mut op2: uint32_t) -> uint32_t {
let mut result: uint32_t = 0;
asm!(
"uqadd16 {0}, {1}, {2}", lateout(reg) result, inlateout(reg) op1 => _,
inlateout(reg) op2 => _, options(preserves_flags, pure, readonly)
);
return result;
}
#[inline(always)]
pub unsafe fn __UHADD16(mut op1: uint32_t, mut op2: uint32_t) -> uint32_t {
let mut result: uint32_t = 0;
asm!(
"uhadd16 {0}, {1}, {2}", lateout(reg) result, inlateout(reg) op1 => _,
inlateout(reg) op2 => _, options(preserves_flags, pure, readonly)
);
return result;
}
#[inline(always)]
pub unsafe fn __SSUB16(mut op1: uint32_t, mut op2: uint32_t) -> uint32_t {
let mut result: uint32_t = 0;
asm!(
"ssub16 {0}, {1}, {2}", lateout(reg) result, inlateout(reg) op1 => _,
inlateout(reg) op2 => _, options(preserves_flags)
);
return result;
}
#[inline(always)]
pub unsafe fn __QSUB16(mut op1: uint32_t, mut op2: uint32_t) -> uint32_t {
let mut result: uint32_t = 0;
asm!(
"qsub16 {0}, {1}, {2}", lateout(reg) result, inlateout(reg) op1 => _,
inlateout(reg) op2 => _, options(preserves_flags, pure, readonly)
);
return result;
}
#[inline(always)]
pub unsafe fn __SHSUB16(mut op1: uint32_t, mut op2: uint32_t) -> uint32_t {
let mut result: uint32_t = 0;
asm!(
"shsub16 {0}, {1}, {2}", lateout(reg) result, inlateout(reg) op1 => _,
inlateout(reg) op2 => _, options(preserves_flags, pure, readonly)
);
return result;
}
#[inline(always)]
pub unsafe fn __USUB16(mut op1: uint32_t, mut op2: uint32_t) -> uint32_t {
let mut result: uint32_t = 0;
asm!(
"usub16 {0}, {1}, {2}", lateout(reg) result, inlateout(reg) op1 => _,
inlateout(reg) op2 => _, options(preserves_flags)
);
return result;
}
#[inline(always)]
pub unsafe fn __UQSUB16(mut op1: uint32_t, mut op2: uint32_t) -> uint32_t {
let mut result: uint32_t = 0;
asm!(
"uqsub16 {0}, {1}, {2}", lateout(reg) result, inlateout(reg) op1 => _,
inlateout(reg) op2 => _, options(preserves_flags, pure, readonly)
);
return result;
}
#[inline(always)]
pub unsafe fn __UHSUB16(mut op1: uint32_t, mut op2: uint32_t) -> uint32_t {
let mut result: uint32_t = 0;
asm!(
"uhsub16 {0}, {1}, {2}", lateout(reg) result, inlateout(reg) op1 => _,
inlateout(reg) op2 => _, options(preserves_flags, pure, readonly)
);
return result;
}
#[inline(always)]
pub unsafe fn __SASX(mut op1: uint32_t, mut op2: uint32_t) -> uint32_t {
let mut result: uint32_t = 0;
asm!(
"sasx {0}, {1}, {2}", lateout(reg) result, inlateout(reg) op1 => _,
inlateout(reg) op2 => _, options(preserves_flags)
);
return result;
}
#[inline(always)]
pub unsafe fn __QASX(mut op1: uint32_t, mut op2: uint32_t) -> uint32_t {
let mut result: uint32_t = 0;
asm!(
"qasx {0}, {1}, {2}", lateout(reg) result, inlateout(reg) op1 => _,
inlateout(reg) op2 => _, options(preserves_flags, pure, readonly)
);
return result;
}
#[inline(always)]
pub unsafe fn __SHASX(mut op1: uint32_t, mut op2: uint32_t) -> uint32_t {
let mut result: uint32_t = 0;
asm!(
"shasx {0}, {1}, {2}", lateout(reg) result, inlateout(reg) op1 => _,
inlateout(reg) op2 => _, options(preserves_flags, pure, readonly)
);
return result;
}
#[inline(always)]
pub unsafe fn __UASX(mut op1: uint32_t, mut op2: uint32_t) -> uint32_t {
let mut result: uint32_t = 0;
asm!(
"uasx {0}, {1}, {2}", lateout(reg) result, inlateout(reg) op1 => _,
inlateout(reg) op2 => _, options(preserves_flags)
);
return result;
}
#[inline(always)]
pub unsafe fn __UQASX(mut op1: uint32_t, mut op2: uint32_t) -> uint32_t {
let mut result: uint32_t = 0;
asm!(
"uqasx {0}, {1}, {2}", lateout(reg) result, inlateout(reg) op1 => _,
inlateout(reg) op2 => _, options(preserves_flags, pure, readonly)
);
return result;
}
#[inline(always)]
pub unsafe fn __UHASX(mut op1: uint32_t, mut op2: uint32_t) -> uint32_t {
let mut result: uint32_t = 0;
asm!(
"uhasx {0}, {1}, {2}", lateout(reg) result, inlateout(reg) op1 => _,
inlateout(reg) op2 => _, options(preserves_flags, pure, readonly)
);
return result;
}
#[inline(always)]
pub unsafe fn __SSAX(mut op1: uint32_t, mut op2: uint32_t) -> uint32_t {
let mut result: uint32_t = 0;
asm!(
"ssax {0}, {1}, {2}", lateout(reg) result, inlateout(reg) op1 => _,
inlateout(reg) op2 => _, options(preserves_flags)
);
return result;
}
#[inline(always)]
pub unsafe fn __QSAX(mut op1: uint32_t, mut op2: uint32_t) -> uint32_t {
let mut result: uint32_t = 0;
asm!(
"qsax {0}, {1}, {2}", lateout(reg) result, inlateout(reg) op1 => _,
inlateout(reg) op2 => _, options(preserves_flags, pure, readonly)
);
return result;
}
#[inline(always)]
pub unsafe fn __SHSAX(mut op1: uint32_t, mut op2: uint32_t) -> uint32_t {
let mut result: uint32_t = 0;
asm!(
"shsax {0}, {1}, {2}", lateout(reg) result, inlateout(reg) op1 => _,
inlateout(reg) op2 => _, options(preserves_flags, pure, readonly)
);
return result;
}
#[inline(always)]
pub unsafe fn __USAX(mut op1: uint32_t, mut op2: uint32_t) -> uint32_t {
let mut result: uint32_t = 0;
asm!(
"usax {0}, {1}, {2}", lateout(reg) result, inlateout(reg) op1 => _,
inlateout(reg) op2 => _, options(preserves_flags)
);
return result;
}
#[inline(always)]
pub unsafe fn __UQSAX(mut op1: uint32_t, mut op2: uint32_t) -> uint32_t {
let mut result: uint32_t = 0;
asm!(
"uqsax {0}, {1}, {2}", lateout(reg) result, inlateout(reg) op1 => _,
inlateout(reg) op2 => _, options(preserves_flags, pure, readonly)
);
return result;
}
#[inline(always)]
pub unsafe fn __UHSAX(mut op1: uint32_t, mut op2: uint32_t) -> uint32_t {
let mut result: uint32_t = 0;
asm!(
"uhsax {0}, {1}, {2}", lateout(reg) result, inlateout(reg) op1 => _,
inlateout(reg) op2 => _, options(preserves_flags, pure, readonly)
);
return result;
}
#[inline(always)]
pub unsafe fn __USAD8(mut op1: uint32_t, mut op2: uint32_t) -> uint32_t {
let mut result: uint32_t = 0;
asm!(
"usad8 {0}, {1}, {2}", lateout(reg) result, inlateout(reg) op1 => _,
inlateout(reg) op2 => _, options(preserves_flags, pure, readonly)
);
return result;
}
#[inline(always)]
pub unsafe fn __USADA8(
mut op1: uint32_t,
mut op2: uint32_t,
mut op3: uint32_t,
) -> uint32_t {
let mut result: uint32_t = 0;
asm!(
"usada8 {0}, {1}, {2}, {3}", lateout(reg) result, inlateout(reg) op1 => _,
inlateout(reg) op2 => _, inlateout(reg) op3 => _, options(preserves_flags, pure,
readonly)
);
return result;
}
#[inline(always)]
pub unsafe fn __UXTB16(mut op1: uint32_t) -> uint32_t {
let mut result: uint32_t = 0;
asm!(
"uxtb16 {0}, {1}", lateout(reg) result, inlateout(reg) op1 => _,
options(preserves_flags, pure, readonly)
);
return result;
}
#[inline(always)]
pub unsafe fn __UXTAB16(mut op1: uint32_t, mut op2: uint32_t) -> uint32_t {
let mut result: uint32_t = 0;
asm!(
"uxtab16 {0}, {1}, {2}", lateout(reg) result, inlateout(reg) op1 => _,
inlateout(reg) op2 => _, options(preserves_flags, pure, readonly)
);
return result;
}
#[inline(always)]
pub unsafe fn __SXTB16(mut op1: uint32_t) -> uint32_t {
let mut result: uint32_t = 0;
asm!(
"sxtb16 {0}, {1}", lateout(reg) result, inlateout(reg) op1 => _,
options(preserves_flags, pure, readonly)
);
return result;
}
#[inline(always)]
pub unsafe fn __SXTB16_RORn(mut op1: uint32_t, mut rotate: uint32_t) -> uint32_t {
let mut result: uint32_t = 0;
if 0 != 0
&& (rotate == 8 as libc::c_uint || rotate == 16 as libc::c_uint
|| rotate == 24 as libc::c_uint)
{
asm!(
"sxtb16 {0}, {1}, ROR {2}", lateout(reg) result, inlateout(reg) op1 => _,
inlateout(reg) rotate => _, options(preserves_flags)
);
} else {
result = __SXTB16(__ROR(op1, rotate));
}
return result;
}
#[inline(always)]
pub unsafe fn __SXTAB16(mut op1: uint32_t, mut op2: uint32_t) -> uint32_t {
let mut result: uint32_t = 0;
asm!(
"sxtab16 {0}, {1}, {2}", lateout(reg) result, inlateout(reg) op1 => _,
inlateout(reg) op2 => _, options(preserves_flags, pure, readonly)
);
return result;
}
#[inline(always)]
pub unsafe fn __SXTAB16_RORn(
mut op1: uint32_t,
mut op2: uint32_t,
mut rotate: uint32_t,
) -> uint32_t {
let mut result: uint32_t = 0;
if 0 != 0
&& (rotate == 8 as libc::c_uint || rotate == 16 as libc::c_uint
|| rotate == 24 as libc::c_uint)
{
asm!(
"sxtab16 {0}, {1}, {2}, ROR {3}", lateout(reg) result, inlateout(reg) op1 =>
_, inlateout(reg) op2 => _, inlateout(reg) rotate => _,
options(preserves_flags)
);
} else {
result = __SXTAB16(op1, __ROR(op2, rotate));
}
return result;
}
#[inline(always)]
pub unsafe fn __SMUAD(mut op1: uint32_t, mut op2: uint32_t) -> uint32_t {
let mut result: uint32_t = 0;
asm!(
"smuad {0}, {1}, {2}", lateout(reg) result, inlateout(reg) op1 => _,
inlateout(reg) op2 => _, options(preserves_flags)
);
return result;
}
#[inline(always)]
pub unsafe fn __SMUADX(mut op1: uint32_t, mut op2: uint32_t) -> uint32_t {
let mut result: uint32_t = 0;
asm!(
"smuadx {0}, {1}, {2}", lateout(reg) result, inlateout(reg) op1 => _,
inlateout(reg) op2 => _, options(preserves_flags)
);
return result;
}
#[inline(always)]
pub unsafe fn __SMLAD(
mut op1: uint32_t,
mut op2: uint32_t,
mut op3: uint32_t,
) -> uint32_t {
let mut result: uint32_t = 0;
asm!(
"smlad {0}, {1}, {2}, {3}", lateout(reg) result, inlateout(reg) op1 => _,
inlateout(reg) op2 => _, inlateout(reg) op3 => _, options(preserves_flags)
);
return result;
}
#[inline(always)]
pub unsafe fn __SMLADX(
mut op1: uint32_t,
mut op2: uint32_t,
mut op3: uint32_t,
) -> uint32_t {
let mut result: uint32_t = 0;
asm!(
"smladx {0}, {1}, {2}, {3}", lateout(reg) result, inlateout(reg) op1 => _,
inlateout(reg) op2 => _, inlateout(reg) op3 => _, options(preserves_flags)
);
return result;
}
#[inline(always)]
#[cfg(c2rust_fixed_309)]
pub unsafe fn __SMLALD(
mut op1: uint32_t,
mut op2: uint32_t,
mut acc: uint64_t,
) -> uint64_t {
let mut llr: llreg_u = llreg_u { w32: [0; 2] };
llr.w64 = acc;
let fresh4 = &mut llr.w32[0 as libc::c_int as usize];
let fresh5;
let fresh6 = llr.w32[0 as libc::c_int as usize];
let fresh7 = &mut llr.w32[1 as libc::c_int as usize];
let fresh8;
let fresh9 = llr.w32[1 as libc::c_int as usize];
asm!(
"smlald {0}, {1}, {2}, {3}", inlateout(reg)
c2rust_asm_casts::AsmCast::cast_in(fresh4, fresh6) => fresh5, inlateout(reg)
c2rust_asm_casts::AsmCast::cast_in(fresh7, fresh9) => fresh8, inlateout(reg) op1
=> _, inlateout(reg) op2 => _, options(preserves_flags)
);
c2rust_asm_casts::AsmCast::cast_out(fresh4, fresh6, fresh5);
c2rust_asm_casts::AsmCast::cast_out(fresh7, fresh9, fresh8);
return llr.w64;
}
#[inline(always)]
#[cfg(c2rust_fixed_309)]
pub unsafe fn __SMLALDX(
mut op1: uint32_t,
mut op2: uint32_t,
mut acc: uint64_t,
) -> uint64_t {
let mut llr: llreg_u_0 = llreg_u_0 { w32: [0; 2] };
llr.w64 = acc;
let fresh10 = &mut llr.w32[0 as libc::c_int as usize];
let fresh11;
let fresh12 = llr.w32[0 as libc::c_int as usize];
let fresh13 = &mut llr.w32[1 as libc::c_int as usize];
let fresh14;
let fresh15 = llr.w32[1 as libc::c_int as usize];
asm!(
"smlaldx {0}, {1}, {2}, {3}", inlateout(reg)
c2rust_asm_casts::AsmCast::cast_in(fresh10, fresh12) => fresh11, inlateout(reg)
c2rust_asm_casts::AsmCast::cast_in(fresh13, fresh15) => fresh14, inlateout(reg)
op1 => _, inlateout(reg) op2 => _, options(preserves_flags)
);
c2rust_asm_casts::AsmCast::cast_out(fresh10, fresh12, fresh11);
c2rust_asm_casts::AsmCast::cast_out(fresh13, fresh15, fresh14);
return llr.w64;
}
#[inline(always)]
pub unsafe fn __SMUSD(mut op1: uint32_t, mut op2: uint32_t) -> uint32_t {
let mut result: uint32_t = 0;
asm!(
"smusd {0}, {1}, {2}", lateout(reg) result, inlateout(reg) op1 => _,
inlateout(reg) op2 => _, options(preserves_flags)
);
return result;
}
#[inline(always)]
pub unsafe fn __SMUSDX(mut op1: uint32_t, mut op2: uint32_t) -> uint32_t {
let mut result: uint32_t = 0;
asm!(
"smusdx {0}, {1}, {2}", lateout(reg) result, inlateout(reg) op1 => _,
inlateout(reg) op2 => _, options(preserves_flags)
);
return result;
}
#[inline(always)]
pub unsafe fn __SMLSD(
mut op1: uint32_t,
mut op2: uint32_t,
mut op3: uint32_t,
) -> uint32_t {
let mut result: uint32_t = 0;
asm!(
"smlsd {0}, {1}, {2}, {3}", lateout(reg) result, inlateout(reg) op1 => _,
inlateout(reg) op2 => _, inlateout(reg) op3 => _, options(preserves_flags)
);
return result;
}
#[inline(always)]
pub unsafe fn __SMLSDX(
mut op1: uint32_t,
mut op2: uint32_t,
mut op3: uint32_t,
) -> uint32_t {
let mut result: uint32_t = 0;
asm!(
"smlsdx {0}, {1}, {2}, {3}", lateout(reg) result, inlateout(reg) op1 => _,
inlateout(reg) op2 => _, inlateout(reg) op3 => _, options(preserves_flags)
);
return result;
}
#[inline(always)]
#[cfg(c2rust_fixed_309)]
pub unsafe fn __SMLSLD(
mut op1: uint32_t,
mut op2: uint32_t,
mut acc: uint64_t,
) -> uint64_t {
let mut llr: llreg_u_1 = llreg_u_1 { w32: [0; 2] };
llr.w64 = acc;
let fresh16 = &mut llr.w32[0 as libc::c_int as usize];
let fresh17;
let fresh18 = llr.w32[0 as libc::c_int as usize];
let fresh19 = &mut llr.w32[1 as libc::c_int as usize];
let fresh20;
let fresh21 = llr.w32[1 as libc::c_int as usize];
asm!(
"smlsld {0}, {1}, {2}, {3}", inlateout(reg)
c2rust_asm_casts::AsmCast::cast_in(fresh16, fresh18) => fresh17, inlateout(reg)
c2rust_asm_casts::AsmCast::cast_in(fresh19, fresh21) => fresh20, inlateout(reg)
op1 => _, inlateout(reg) op2 => _, options(preserves_flags)
);
c2rust_asm_casts::AsmCast::cast_out(fresh16, fresh18, fresh17);
c2rust_asm_casts::AsmCast::cast_out(fresh19, fresh21, fresh20);
return llr.w64;
}
#[inline(always)]
#[cfg(c2rust_fixed_309)]
pub unsafe fn __SMLSLDX(
mut op1: uint32_t,
mut op2: uint32_t,
mut acc: uint64_t,
) -> uint64_t {
let mut llr: llreg_u_2 = llreg_u_2 { w32: [0; 2] };
llr.w64 = acc;
let fresh22 = &mut llr.w32[0 as libc::c_int as usize];
let fresh23;
let fresh24 = llr.w32[0 as libc::c_int as usize];
let fresh25 = &mut llr.w32[1 as libc::c_int as usize];
let fresh26;
let fresh27 = llr.w32[1 as libc::c_int as usize];
asm!(
"smlsldx {0}, {1}, {2}, {3}", inlateout(reg)
c2rust_asm_casts::AsmCast::cast_in(fresh22, fresh24) => fresh23, inlateout(reg)
c2rust_asm_casts::AsmCast::cast_in(fresh25, fresh27) => fresh26, inlateout(reg)
op1 => _, inlateout(reg) op2 => _, options(preserves_flags)
);
c2rust_asm_casts::AsmCast::cast_out(fresh22, fresh24, fresh23);
c2rust_asm_casts::AsmCast::cast_out(fresh25, fresh27, fresh26);
return llr.w64;
}
#[inline(always)]
pub unsafe fn __SEL(mut op1: uint32_t, mut op2: uint32_t) -> uint32_t {
let mut result: uint32_t = 0;
asm!(
"sel {0}, {1}, {2}", lateout(reg) result, inlateout(reg) op1 => _, inlateout(reg)
op2 => _, options(preserves_flags)
);
return result;
}
#[inline(always)]
pub unsafe fn __QADD(mut op1: int32_t, mut op2: int32_t) -> int32_t {
let mut result: int32_t = 0;
asm!(
"qadd {0}, {1}, {2}", lateout(reg) result, inlateout(reg) op1 => _,
inlateout(reg) op2 => _, options(preserves_flags)
);
return result;
}
#[inline(always)]
pub unsafe fn __QSUB(mut op1: int32_t, mut op2: int32_t) -> int32_t {
let mut result: int32_t = 0;
asm!(
"qsub {0}, {1}, {2}", lateout(reg) result, inlateout(reg) op1 => _,
inlateout(reg) op2 => _, options(preserves_flags)
);
return result;
}
#[inline(always)]
pub unsafe fn __SMMLA(
mut op1: int32_t,
mut op2: int32_t,
mut op3: int32_t,
) -> int32_t {
let mut result: int32_t = 0;
asm!(
"smmla {0}, {1}, {2}, {3}", lateout(reg) result, inlateout(reg) op1 => _,
inlateout(reg) op2 => _, inlateout(reg) op3 => _, options(preserves_flags, pure,
readonly)
);
return result;
}
#[inline]
pub unsafe fn __NVIC_SetPriorityGrouping(mut PriorityGroup: uint32_t) {
let mut reg_value: uint32_t = 0;
let mut PriorityGroupTmp: uint32_t = PriorityGroup
& 0x7 as libc::c_ulong as uint32_t;
reg_value = (*(SCB as *mut SCB_Type)).AIRCR;
reg_value &= !((SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk) as uint32_t);
reg_value = reg_value | (0x5fa as libc::c_ulong as uint32_t) << SCB_AIRCR_VECTKEY_Pos
| PriorityGroupTmp << SCB_AIRCR_PRIGROUP_Pos;
::core::ptr::write_volatile(
&mut (*(SCB as *mut SCB_Type)).AIRCR as *mut uint32_t,
reg_value,
);
}
pub const SCS_BASE: libc::c_ulong = 0xe000e000 as libc::c_ulong;
pub const SCB_BASE: libc::c_ulong = SCS_BASE.wrapping_add(0xd00 as libc::c_ulong);
pub const SCB: libc::c_ulong = SCB_BASE;
pub const SCB_AIRCR_PRIGROUP_Pos: libc::c_uint = 8 as libc::c_uint;
pub const SCB_AIRCR_VECTKEY_Pos: libc::c_uint = 16 as libc::c_uint;
pub const SCB_AIRCR_PRIGROUP_Msk: libc::c_ulong = (7 as libc::c_ulong)
<< SCB_AIRCR_PRIGROUP_Pos;
pub const SCB_AIRCR_VECTKEY_Msk: libc::c_ulong = (0xffff as libc::c_ulong)
<< SCB_AIRCR_VECTKEY_Pos;
#[inline]
pub unsafe fn __NVIC_GetPriorityGrouping() -> uint32_t {
return (((*(SCB as *mut SCB_Type)).AIRCR as libc::c_ulong & SCB_AIRCR_PRIGROUP_Msk)
>> SCB_AIRCR_PRIGROUP_Pos) as uint32_t;
}
#[inline]
pub unsafe fn __NVIC_EnableIRQ(mut IRQn: IRQn_Type) {
if IRQn as int32_t >= 0 as libc::c_int {
asm!("", options(preserves_flags));
::core::ptr::write_volatile(
&mut (*(NVIC as *mut NVIC_Type))
.ISER[(IRQn as uint32_t >> 5 as libc::c_ulong) as usize]
as *mut uint32_t,
((1 as libc::c_ulong)
<< (IRQn as uint32_t as libc::c_ulong & 0x1f as libc::c_ulong))
as uint32_t,
);
asm!("", options(preserves_flags));
}
}
pub const NVIC_BASE: libc::c_ulong = SCS_BASE.wrapping_add(0x100 as libc::c_ulong);
pub const NVIC: libc::c_ulong = NVIC_BASE;
#[inline]
pub unsafe fn __NVIC_GetEnableIRQ(mut IRQn: IRQn_Type) -> uint32_t {
if IRQn as int32_t >= 0 as libc::c_int {
return (if (*(NVIC as *mut NVIC_Type))
.ISER[(IRQn as uint32_t >> 5 as libc::c_ulong) as usize] as libc::c_ulong
& (1 as libc::c_ulong)
<< (IRQn as uint32_t as libc::c_ulong & 0x1f as libc::c_ulong)
!= 0 as libc::c_ulong
{
1 as libc::c_ulong
} else {
0 as libc::c_ulong
}) as uint32_t
} else {
return 0 as libc::c_uint
};
}
#[inline]
pub unsafe fn __NVIC_DisableIRQ(mut IRQn: IRQn_Type) {
if IRQn as int32_t >= 0 as libc::c_int {
::core::ptr::write_volatile(
&mut (*(NVIC as *mut NVIC_Type))
.ICER[(IRQn as uint32_t >> 5 as libc::c_ulong) as usize]
as *mut uint32_t,
((1 as libc::c_ulong)
<< (IRQn as uint32_t as libc::c_ulong & 0x1f as libc::c_ulong))
as uint32_t,
);
__DSB();
__ISB();
}
}
#[inline]
pub unsafe fn __NVIC_GetPendingIRQ(mut IRQn: IRQn_Type) -> uint32_t {
if IRQn as int32_t >= 0 as libc::c_int {
return (if (*(NVIC as *mut NVIC_Type))
.ISPR[(IRQn as uint32_t >> 5 as libc::c_ulong) as usize] as libc::c_ulong
& (1 as libc::c_ulong)
<< (IRQn as uint32_t as libc::c_ulong & 0x1f as libc::c_ulong)
!= 0 as libc::c_ulong
{
1 as libc::c_ulong
} else {
0 as libc::c_ulong
}) as uint32_t
} else {
return 0 as libc::c_uint
};
}
#[inline]
pub unsafe fn __NVIC_SetPendingIRQ(mut IRQn: IRQn_Type) {
if IRQn as int32_t >= 0 as libc::c_int {
::core::ptr::write_volatile(
&mut (*(NVIC as *mut NVIC_Type))
.ISPR[(IRQn as uint32_t >> 5 as libc::c_ulong) as usize]
as *mut uint32_t,
((1 as libc::c_ulong)
<< (IRQn as uint32_t as libc::c_ulong & 0x1f as libc::c_ulong))
as uint32_t,
);
}
}
#[inline]
pub unsafe fn __NVIC_ClearPendingIRQ(mut IRQn: IRQn_Type) {
if IRQn as int32_t >= 0 as libc::c_int {
::core::ptr::write_volatile(
&mut (*(NVIC as *mut NVIC_Type))
.ICPR[(IRQn as uint32_t >> 5 as libc::c_ulong) as usize]
as *mut uint32_t,
((1 as libc::c_ulong)
<< (IRQn as uint32_t as libc::c_ulong & 0x1f as libc::c_ulong))
as uint32_t,
);
}
}
#[inline]
pub unsafe fn __NVIC_GetActive(mut IRQn: IRQn_Type) -> uint32_t {
if IRQn as int32_t >= 0 as libc::c_int {
return (if (*(NVIC as *mut NVIC_Type))
.IABR[(IRQn as uint32_t >> 5 as libc::c_ulong) as usize] as libc::c_ulong
& (1 as libc::c_ulong)
<< (IRQn as uint32_t as libc::c_ulong & 0x1f as libc::c_ulong)
!= 0 as libc::c_ulong
{
1 as libc::c_ulong
} else {
0 as libc::c_ulong
}) as uint32_t
} else {
return 0 as libc::c_uint
};
}
#[inline]
unsafe extern "C" fn __NVIC_SetPriority(mut IRQn: IRQn_Type, mut priority: uint32_t) {
if IRQn as int32_t >= 0 as libc::c_int {
::core::ptr::write_volatile(
&mut (*(NVIC as *mut NVIC_Type)).IP[IRQn as uint32_t as usize]
as *mut uint8_t,
(priority
<< (8 as libc::c_uint).wrapping_sub(__NVIC_PRIO_BITS as libc::c_uint)
& 0xff as libc::c_ulong as uint32_t) as uint8_t,
);
} else {
::core::ptr::write_volatile(
&mut (*(SCB as *mut SCB_Type))
.SHP[(IRQn as uint32_t as libc::c_ulong & 0xf as libc::c_ulong)
.wrapping_sub(4 as libc::c_ulong) as usize] as *mut uint8_t,
(priority
<< (8 as libc::c_uint).wrapping_sub(__NVIC_PRIO_BITS as libc::c_uint)
& 0xff as libc::c_ulong as uint32_t) as uint8_t,
);
};
}
pub const __NVIC_PRIO_BITS: libc::c_int = 3 as libc::c_int;
#[inline]
pub unsafe fn __NVIC_GetPriority(mut IRQn: IRQn_Type) -> uint32_t {
if IRQn as int32_t >= 0 as libc::c_int {
return (*(NVIC as *mut NVIC_Type)).IP[IRQn as uint32_t as usize] as uint32_t
>> (8 as libc::c_uint).wrapping_sub(__NVIC_PRIO_BITS as libc::c_uint)
} else {
return (*(SCB as *mut SCB_Type))
.SHP[(IRQn as uint32_t as libc::c_ulong & 0xf as libc::c_ulong)
.wrapping_sub(4 as libc::c_ulong) as usize] as uint32_t
>> (8 as libc::c_uint).wrapping_sub(__NVIC_PRIO_BITS as libc::c_uint)
};
}
#[inline]
pub unsafe fn NVIC_EncodePriority(
mut PriorityGroup: uint32_t,
mut PreemptPriority: uint32_t,
mut SubPriority: uint32_t,
) -> uint32_t {
let mut PriorityGroupTmp: uint32_t = PriorityGroup
& 0x7 as libc::c_ulong as uint32_t;
let mut PreemptPriorityBits: uint32_t = 0;
let mut SubPriorityBits: uint32_t = 0;
PreemptPriorityBits = if (7 as libc::c_ulong)
.wrapping_sub(PriorityGroupTmp as libc::c_ulong)
> 3 as libc::c_int as uint32_t as libc::c_ulong
{
3 as libc::c_int as uint32_t
} else {
(7 as libc::c_ulong).wrapping_sub(PriorityGroupTmp as libc::c_ulong) as uint32_t
};
SubPriorityBits = if PriorityGroupTmp.wrapping_add(3 as libc::c_int as uint32_t)
< 7 as libc::c_ulong as uint32_t
{
0 as libc::c_ulong as uint32_t
} else {
(PriorityGroupTmp as libc::c_ulong)
.wrapping_sub(7 as libc::c_ulong)
.wrapping_add(3 as libc::c_int as uint32_t as libc::c_ulong) as uint32_t
};
return (PreemptPriority
& ((1 as libc::c_ulong) << PreemptPriorityBits).wrapping_sub(1 as libc::c_ulong)
as uint32_t) << SubPriorityBits
| SubPriority
& ((1 as libc::c_ulong) << SubPriorityBits).wrapping_sub(1 as libc::c_ulong)
as uint32_t;
}
#[inline]
pub unsafe fn NVIC_DecodePriority(
mut Priority: uint32_t,
mut PriorityGroup: uint32_t,
pPreemptPriority: *mut uint32_t,
pSubPriority: *mut uint32_t,
) {
let mut PriorityGroupTmp: uint32_t = PriorityGroup
& 0x7 as libc::c_ulong as uint32_t;
let mut PreemptPriorityBits: uint32_t = 0;
let mut SubPriorityBits: uint32_t = 0;
PreemptPriorityBits = if (7 as libc::c_ulong)
.wrapping_sub(PriorityGroupTmp as libc::c_ulong)
> 3 as libc::c_int as uint32_t as libc::c_ulong
{
3 as libc::c_int as uint32_t
} else {
(7 as libc::c_ulong).wrapping_sub(PriorityGroupTmp as libc::c_ulong) as uint32_t
};
SubPriorityBits = if PriorityGroupTmp.wrapping_add(3 as libc::c_int as uint32_t)
< 7 as libc::c_ulong as uint32_t
{
0 as libc::c_ulong as uint32_t
} else {
(PriorityGroupTmp as libc::c_ulong)
.wrapping_sub(7 as libc::c_ulong)
.wrapping_add(3 as libc::c_int as uint32_t as libc::c_ulong) as uint32_t
};
*pPreemptPriority = Priority >> SubPriorityBits
& ((1 as libc::c_ulong) << PreemptPriorityBits).wrapping_sub(1 as libc::c_ulong)
as uint32_t;
*pSubPriority = Priority
& ((1 as libc::c_ulong) << SubPriorityBits).wrapping_sub(1 as libc::c_ulong)
as uint32_t;
}
#[inline]
pub unsafe fn __NVIC_SetVector(mut IRQn: IRQn_Type, mut vector: uint32_t) {
let mut vectors: *mut uint32_t = (*(SCB as *mut SCB_Type)).VTOR as *mut uint32_t;
*vectors.offset((IRQn as int32_t + NVIC_USER_IRQ_OFFSET) as isize) = vector;
}
pub const NVIC_USER_IRQ_OFFSET: libc::c_int = 16 as libc::c_int;
#[inline]
pub unsafe fn __NVIC_GetVector(mut IRQn: IRQn_Type) -> uint32_t {
let mut vectors: *mut uint32_t = (*(SCB as *mut SCB_Type)).VTOR as *mut uint32_t;
return *vectors.offset((IRQn as int32_t + NVIC_USER_IRQ_OFFSET) as isize);
}
#[inline]
pub unsafe fn __NVIC_SystemReset() -> ! {
__DSB();
::core::ptr::write_volatile(
&mut (*(SCB as *mut SCB_Type)).AIRCR as *mut uint32_t,
((0x5fa as libc::c_ulong) << SCB_AIRCR_VECTKEY_Pos
| (*(SCB as *mut SCB_Type)).AIRCR as libc::c_ulong & SCB_AIRCR_PRIGROUP_Msk
| SCB_AIRCR_SYSRESETREQ_Msk) as uint32_t,
);
__DSB();
loop {
asm!("nop", options(preserves_flags));
};
}
pub const SCB_AIRCR_SYSRESETREQ_Pos: libc::c_uint = 2 as libc::c_uint;
pub const SCB_AIRCR_SYSRESETREQ_Msk: libc::c_ulong = (1 as libc::c_ulong)
<< SCB_AIRCR_SYSRESETREQ_Pos;
#[inline]
pub unsafe fn ARM_MPU_Enable(mut MPU_Control: uint32_t) {
__DMB();
::core::ptr::write_volatile(
&mut (*(MPU as *mut MPU_Type)).CTRL as *mut uint32_t,
(MPU_Control as libc::c_ulong | MPU_CTRL_ENABLE_Msk) as uint32_t,
);
let ref mut fresh28 = (*(SCB as *mut SCB_Type)).SHCSR;
::core::ptr::write_volatile(
fresh28,
(::core::ptr::read_volatile::<uint32_t>(fresh28 as *const uint32_t)
as libc::c_ulong | SCB_SHCSR_MEMFAULTENA_Msk) as uint32_t as uint32_t,
);
__DSB();
__ISB();
}
pub const SCB_SHCSR_MEMFAULTENA_Pos: libc::c_uint = 16 as libc::c_uint;
pub const SCB_SHCSR_MEMFAULTENA_Msk: libc::c_ulong = (1 as libc::c_ulong)
<< SCB_SHCSR_MEMFAULTENA_Pos;
pub const MPU_CTRL_ENABLE_Msk: libc::c_ulong = 1 as libc::c_ulong;
pub const MPU_BASE: libc::c_ulong = SCS_BASE.wrapping_add(0xd90 as libc::c_ulong);
pub const MPU: libc::c_ulong = MPU_BASE;
#[inline]
pub unsafe fn ARM_MPU_Disable() {
__DMB();
let ref mut fresh29 = (*(SCB as *mut SCB_Type)).SHCSR;
::core::ptr::write_volatile(
fresh29,
(::core::ptr::read_volatile::<uint32_t>(fresh29 as *const uint32_t)
as libc::c_ulong & !SCB_SHCSR_MEMFAULTENA_Msk) as uint32_t as uint32_t,
);
let ref mut fresh30 = (*(MPU as *mut MPU_Type)).CTRL;
::core::ptr::write_volatile(
fresh30,
(::core::ptr::read_volatile::<uint32_t>(fresh30 as *const uint32_t)
as libc::c_ulong & !MPU_CTRL_ENABLE_Msk) as uint32_t as uint32_t,
);
__DSB();
__ISB();
}
#[inline]
pub unsafe fn ARM_MPU_ClrRegion(mut rnr: uint32_t) {
::core::ptr::write_volatile(
&mut (*(MPU as *mut MPU_Type)).RNR as *mut uint32_t,
rnr,
);
::core::ptr::write_volatile(
&mut (*(MPU as *mut MPU_Type)).RASR as *mut uint32_t,
0 as libc::c_uint,
);
}
#[inline]
pub unsafe fn ARM_MPU_SetRegion(mut rbar: uint32_t, mut rasr: uint32_t) {
::core::ptr::write_volatile(
&mut (*(MPU as *mut MPU_Type)).RBAR as *mut uint32_t,
rbar,
);
::core::ptr::write_volatile(
&mut (*(MPU as *mut MPU_Type)).RASR as *mut uint32_t,
rasr,
);
}
#[inline]
pub unsafe fn ARM_MPU_SetRegionEx(
mut rnr: uint32_t,
mut rbar: uint32_t,
mut rasr: uint32_t,
) {
::core::ptr::write_volatile(
&mut (*(MPU as *mut MPU_Type)).RNR as *mut uint32_t,
rnr,
);
::core::ptr::write_volatile(
&mut (*(MPU as *mut MPU_Type)).RBAR as *mut uint32_t,
rbar,
);
::core::ptr::write_volatile(
&mut (*(MPU as *mut MPU_Type)).RASR as *mut uint32_t,
rasr,
);
}
#[inline]
pub unsafe fn ARM_MPU_OrderedMemcpy(
mut dst: *mut uint32_t,
mut src: *const uint32_t,
mut len: uint32_t,
) {
let mut i: uint32_t = 0;
i = 0 as libc::c_uint;
while i < len {
::core::ptr::write_volatile(dst.offset(i as isize), *src.offset(i as isize));
i = i.wrapping_add(1);
i;
}
}
#[inline]
pub unsafe fn ARM_MPU_Load(
mut table: *const ARM_MPU_Region_t,
mut cnt: uint32_t,
) {
let rowWordSize: uint32_t = (::core::mem::size_of::<ARM_MPU_Region_t>()
as libc::c_ulong)
.wrapping_div(4 as libc::c_uint);
while cnt > MPU_TYPE_RALIASES {
ARM_MPU_OrderedMemcpy(
&mut (*(MPU as *mut MPU_Type)).RBAR,
&(*table).RBAR,
MPU_TYPE_RALIASES.wrapping_mul(rowWordSize),
);
table = table.offset(MPU_TYPE_RALIASES as isize);
cnt = (cnt as libc::c_uint).wrapping_sub(MPU_TYPE_RALIASES) as uint32_t
as uint32_t;
}
ARM_MPU_OrderedMemcpy(
&mut (*(MPU as *mut MPU_Type)).RBAR,
&(*table).RBAR,
cnt.wrapping_mul(rowWordSize),
);
}
pub const MPU_TYPE_RALIASES: libc::c_uint = 4 as libc::c_uint;
#[inline]
pub unsafe fn SCB_GetFPUType() -> uint32_t {
let mut mvfr0: uint32_t = 0;
mvfr0 = (*(FPU as *mut FPU_Type)).MVFR0;
if mvfr0 as libc::c_ulong
& (FPU_MVFR0_Single_precision_Msk | FPU_MVFR0_Double_precision_Msk)
== 0x20 as libc::c_uint as libc::c_ulong
{
return 1 as libc::c_uint
} else {
return 0 as libc::c_uint
};
}
pub const FPU_MVFR0_Double_precision_Pos: libc::c_uint = 8 as libc::c_uint;
pub const FPU_MVFR0_Double_precision_Msk: libc::c_ulong = (0xf as libc::c_ulong)
<< FPU_MVFR0_Double_precision_Pos;
pub const FPU_MVFR0_Single_precision_Pos: libc::c_uint = 4 as libc::c_uint;
pub const FPU_MVFR0_Single_precision_Msk: libc::c_ulong = (0xf as libc::c_ulong)
<< FPU_MVFR0_Single_precision_Pos;
pub const FPU_BASE: libc::c_ulong = SCS_BASE.wrapping_add(0xf30 as libc::c_ulong);
pub const FPU: libc::c_ulong = FPU_BASE;
#[inline]
pub unsafe fn SysTick_Config(mut ticks: uint32_t) -> uint32_t {
if (ticks as libc::c_ulong).wrapping_sub(1 as libc::c_ulong)
> SysTick_LOAD_RELOAD_Msk
{
return 1 as libc::c_ulong as uint32_t;
}
::core::ptr::write_volatile(
&mut (*(SysTick as *mut SysTick_Type)).LOAD as *mut uint32_t,
(ticks as libc::c_ulong).wrapping_sub(1 as libc::c_ulong) as uint32_t,
);
__NVIC_SetPriority(
SysTick_IRQn,
((1 as libc::c_ulong) << __NVIC_PRIO_BITS).wrapping_sub(1 as libc::c_ulong)
as uint32_t,
);
::core::ptr::write_volatile(
&mut (*(SysTick as *mut SysTick_Type)).VAL as *mut uint32_t,
0 as libc::c_ulong as uint32_t,
);
::core::ptr::write_volatile(
&mut (*(SysTick as *mut SysTick_Type)).CTRL as *mut uint32_t,
(SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_TICKINT_Msk | SysTick_CTRL_ENABLE_Msk)
as uint32_t,
);
return 0 as libc::c_ulong as uint32_t;
}
pub const SysTick_CTRL_ENABLE_Msk: libc::c_ulong = 1 as libc::c_ulong;
pub const SysTick_CTRL_TICKINT_Pos: libc::c_uint = 1 as libc::c_uint;
pub const SysTick_CTRL_TICKINT_Msk: libc::c_ulong = (1 as libc::c_ulong)
<< SysTick_CTRL_TICKINT_Pos;
pub const SysTick_CTRL_CLKSOURCE_Pos: libc::c_uint = 2 as libc::c_uint;
pub const SysTick_CTRL_CLKSOURCE_Msk: libc::c_ulong = (1 as libc::c_ulong)
<< SysTick_CTRL_CLKSOURCE_Pos;
pub const SysTick_BASE: libc::c_ulong = SCS_BASE.wrapping_add(0x10 as libc::c_ulong);
pub const SysTick: libc::c_ulong = SysTick_BASE;
pub const NVIC_SetPriority: unsafe extern "C" fn(IRQn_Type, uint32_t) -> () = __NVIC_SetPriority;
pub const SysTick_LOAD_RELOAD_Msk: libc::c_ulong = 0xffffff as libc::c_ulong;
#[inline]
pub unsafe fn ITM_SendChar(mut ch: uint32_t) -> uint32_t {
if (*(ITM as *mut ITM_Type)).TCR as libc::c_ulong & ITM_TCR_ITMENA_Msk
!= 0 as libc::c_ulong
&& (*(ITM as *mut ITM_Type)).TER as libc::c_ulong & 1 as libc::c_ulong
!= 0 as libc::c_ulong
{
while (*(ITM as *mut ITM_Type)).PORT[0 as libc::c_uint as usize].u32_0
as libc::c_ulong == 0 as libc::c_ulong
{
asm!("nop", options(preserves_flags));
}
::core::ptr::write_volatile(
&mut (*(ITM as *mut ITM_Type)).PORT[0 as libc::c_uint as usize].u8_0
as *mut uint8_t,
ch as uint8_t,
);
}
return ch;
}
pub const ITM_BASE: libc::c_ulong = 0xe0000000 as libc::c_ulong;
pub const ITM: libc::c_ulong = ITM_BASE;
pub const ITM_TCR_ITMENA_Msk: libc::c_ulong = 1 as libc::c_ulong;
#[inline]
pub unsafe fn ITM_ReceiveChar() -> int32_t {
let mut ch: int32_t = -(1 as libc::c_int);
if ITM_RxBuffer != ITM_RXBUFFER_EMPTY as int32_t {
ch = ITM_RxBuffer;
::core::ptr::write_volatile(
&mut ITM_RxBuffer as *mut int32_t,
ITM_RXBUFFER_EMPTY as int32_t,
);
}
return ch;
}
pub const ITM_RXBUFFER_EMPTY: libc::c_uint = 0x5aa55aa5 as libc::c_uint;
#[inline]
pub unsafe fn ITM_CheckChar() -> int32_t {
if ITM_RxBuffer == ITM_RXBUFFER_EMPTY as int32_t {
return 0 as libc::c_int
} else {
return 1 as libc::c_int
};
}
#[inline]
pub unsafe fn nrf52_sleep() {
asm!("sev", options(preserves_flags));
asm!("wfe", options(preserves_flags));
asm!("nop", options(preserves_flags));
}
#[inline(always)]
pub unsafe fn thread_yield_higher() {
::core::ptr::write_volatile(
&mut (*(SCB as *mut SCB_Type)).ICSR as *mut uint32_t,
SCB_ICSR_PENDSVSET_Msk as uint32_t,
);
__ISB();
}
pub const SCB_ICSR_PENDSVSET_Pos: libc::c_uint = 28 as libc::c_uint;
pub const SCB_ICSR_PENDSVSET_Msk: libc::c_ulong = (1 as libc::c_ulong)
<< SCB_ICSR_PENDSVSET_Pos;
#[inline]
pub unsafe fn thread_get_unchecked(mut pid: kernel_pid_t) -> *mut thread_t {
return sched_threads[pid as usize] as *mut thread_t;
}
#[inline]
pub unsafe fn thread_get(mut pid: kernel_pid_t) -> *mut thread_t {
if pid_is_valid(pid) != 0 {
return thread_get_unchecked(pid);
}
return NULL as *mut thread_t;
}
#[inline]
pub unsafe fn thread_getpid() -> kernel_pid_t {
extern "C" {
static mut sched_active_pid: kernel_pid_t;
}
return sched_active_pid;
}
#[inline]
pub unsafe fn thread_get_active() -> *mut thread_t {
extern "C" {
static mut sched_active_thread: *mut thread_t;
}
return sched_active_thread as *mut thread_t;
}
#[inline]
pub unsafe fn thread_has_msg_queue(mut thread: *const _thread) -> libc::c_int {
return ((*thread).msg_array != NULL as *mut msg_t) as libc::c_int;
}
#[inline]
pub unsafe fn thread_get_status(mut thread: *const thread_t) -> thread_status_t {
return (*thread).status;
}
#[inline]
pub unsafe fn thread_get_priority(mut thread: *const thread_t) -> uint8_t {
return (*thread).priority;
}
#[inline]
pub unsafe fn thread_is_active(mut thread: *const thread_t) -> bool {
return (*thread).status as libc::c_int >= STATUS_ON_RUNQUEUE;
}
pub const STATUS_ON_RUNQUEUE: libc::c_int = STATUS_RUNNING as libc::c_int;
#[inline]
pub unsafe fn thread_get_stackstart(
mut thread: *const thread_t,
) -> *mut libc::c_void {
return (*thread).stack_start as *mut libc::c_void;
}
#[inline]
pub unsafe fn thread_get_sp(mut thread: *const thread_t) -> *mut libc::c_void {
return (*thread).sp as *mut libc::c_void;
}
#[inline]
pub unsafe fn thread_get_stacksize(mut thread: *const thread_t) -> size_t {
return (*thread).stack_size as size_t;
}
#[inline]
pub unsafe fn thread_getpid_of(mut thread: *const thread_t) -> kernel_pid_t {
return (*thread).pid;
}
#[inline]
pub unsafe fn thread_get_name(
mut thread: *const thread_t,
) -> *const libc::c_char {
return (*thread).name;
}
#[inline]
pub unsafe fn thread_measure_stack_free(
mut thread: *const thread_t,
) -> uintptr_t {
return measure_stack_free_internal(
thread_get_stackstart(thread) as *const libc::c_char,
thread_get_stacksize(thread),
);
}
#[inline]
pub unsafe fn mutex_init(mut mutex: *mut mutex_t) {
(*mutex).queue.next = NULL as *mut list_node;
}
#[inline]
pub unsafe fn mutex_init_locked(mut mutex: *mut mutex_t) {
*mutex = {
let mut init = mutex_t {
queue: {
let mut init = list_node {
next: MUTEX_LOCKED as *mut list_node_t,
};
init
},
};
init
};
}
pub const MUTEX_LOCKED: libc::c_int = -(1 as libc::c_int);
#[inline]
pub unsafe fn mutex_cancel_init(mut mutex: *mut mutex_t) -> mutex_cancel_t {
let mut result: mutex_cancel_t = {
let mut init = mutex_cancel_t {
mutex: mutex,
thread: thread_get_active(),
cancelled: 0 as libc::c_int as uint8_t,
};
init
};
return result;
}
#[inline]
pub unsafe fn mutex_trylock(mut mutex: *mut mutex_t) -> libc::c_int {
return mutex_lock_internal(mutex, false_0 != 0) as libc::c_int;
}
pub const false_0: libc::c_int = 0 as libc::c_int;
#[inline]
pub unsafe fn mutex_lock(mut mutex: *mut mutex_t) {
mutex_lock_internal(mutex, true_0 != 0);
}
pub const true_0: libc::c_int = 1 as libc::c_int;
#[inline]
pub unsafe fn rmutex_init(mut rmutex: *mut rmutex_t) {
let mut empty_rmutex: rmutex_t = {
let mut init = rmutex_t {
mutex: {
let mut init = mutex_t {
queue: {
let mut init = list_node {
next: NULL as *mut list_node,
};
init
},
};
init
},
refcount: 0 as libc::c_int as uint16_t,
owner: KERNEL_PID_UNDEF as kernel_pid_t,
};
init
};
*rmutex = empty_rmutex;
}
pub const SCB_SCR_SLEEPDEEP_Pos: libc::c_uint = 2 as libc::c_uint;
pub const UINT8_MAX: libc::c_int = 255 as libc::c_int;
pub const UINT32_MAX: libc::c_uint = 4294967295 as libc::c_uint;
pub const STATUS_NOT_FOUND: libc::c_int = !(0 as libc::c_int);
#[inline]
pub unsafe fn mtd_dev_get(mut idx: libc::c_uint) -> *mut mtd_dev_t {
if ((mtd_dev_xfa_end.as_mut_ptr() as uintptr_t)
.wrapping_sub(mtd_dev_xfa.as_mut_ptr() as uintptr_t)
.wrapping_div(::core::mem::size_of::<*mut mtd_dev_t>() as libc::c_ulong)
!= 0 as libc::c_int as libc::c_uint) as libc::c_int as uintptr_t as libc::c_long
!= 0
{} else {
_assert_panic();
};
if (idx
< (mtd_dev_xfa_end.as_mut_ptr() as uintptr_t)
.wrapping_sub(mtd_dev_xfa.as_mut_ptr() as uintptr_t)
.wrapping_div(::core::mem::size_of::<*mut mtd_dev_t>() as libc::c_ulong))
as libc::c_int as uintptr_t as libc::c_long != 0
{} else {
_assert_panic();
};
return *mtd_dev_xfa.as_mut_ptr().offset(idx as isize);
}
#[inline]
pub unsafe fn _irq_debug_stop_count() -> uint32_t {
let mut ticks: uint32_t = SysTick_LOAD_RELOAD_Msk
.wrapping_sub((*(SysTick as *mut SysTick_Type)).VAL as libc::c_ulong)
as uint32_t;
::core::ptr::write_volatile(
&mut (*(SysTick as *mut SysTick_Type)).CTRL as *mut uint32_t,
0 as libc::c_int as uint32_t,
);
return ticks;
}
#[inline(always)]
pub unsafe fn irq_disable() -> libc::c_uint {
let mut mask: uint32_t = __get_PRIMASK();
if mask == 0 as libc::c_int as libc::c_uint && 0 as libc::c_int != 0 {
_irq_debug_start_count();
}
__disable_irq();
return mask;
}
#[inline(always)]
pub unsafe fn irq_enable() -> libc::c_uint {
let mut result: libc::c_uint = __get_PRIMASK();
__enable_irq();
return result;
}
#[inline(always)]
pub unsafe fn irq_restore(mut state: libc::c_uint) {
__set_PRIMASK(state);
}
#[inline(always)]
pub unsafe fn irq_is_enabled() -> bool {
return __get_PRIMASK() == 0 as libc::c_int as libc::c_uint;
}
#[inline(always)]
pub unsafe fn irq_is_in() -> bool {
return __get_IPSR() & 0xff as libc::c_int as libc::c_uint != 0;
}
#[inline]
pub unsafe fn cortexm_init_fpu() {
let ref mut fresh31 = (*(SCB as *mut SCB_Type)).CPACR;
::core::ptr::write_volatile(
fresh31,
(::core::ptr::read_volatile::<uint32_t>(fresh31 as *const uint32_t)
as libc::c_uint | CORTEXM_SCB_CPACR_FPU_ACCESS_FULL as uint32_t) as uint32_t
as uint32_t,
);
}
pub const CORTEXM_SCB_CPACR_FPU_ACCESS_FULL: libc::c_int = 0xf00000 as libc::c_int;
#[inline]
pub unsafe fn cpu_get_caller_pc() -> uintptr_t {
let mut lr_ptr: uintptr_t = 0;
asm!("mov {0}, lr", lateout(reg) lr_ptr, options(preserves_flags));
return lr_ptr;
}
#[inline]
pub unsafe fn cortexm_sleep_until_event() {
asm!("wfe", options(preserves_flags));
}
#[inline]
pub unsafe fn cortexm_sleep(mut deep: libc::c_int) {
if deep != 0 {
let ref mut fresh32 = (*(SCB as *mut SCB_Type)).SCR;
::core::ptr::write_volatile(
fresh32,
(::core::ptr::read_volatile::<uint32_t>(fresh32 as *const uint32_t)
as libc::c_ulong | (1 as libc::c_ulong) << SCB_SCR_SLEEPDEEP_Pos)
as uint32_t as uint32_t,
);
} else {
let ref mut fresh33 = (*(SCB as *mut SCB_Type)).SCR;
::core::ptr::write_volatile(
fresh33,
(::core::ptr::read_volatile::<uint32_t>(fresh33 as *const uint32_t)
as libc::c_ulong & !((1 as libc::c_ulong) << SCB_SCR_SLEEPDEEP_Pos))
as uint32_t as uint32_t,
);
}
let mut state: libc::c_uint = irq_disable();
__DSB();
asm!("wfi", options(preserves_flags));
irq_restore(state);
}
#[inline]
pub unsafe fn gpio_is_equal(mut gpio1: gpio_t, mut gpio2: gpio_t) -> libc::c_int {
return (gpio1 as libc::c_int == gpio2 as libc::c_int) as libc::c_int;
}
#[inline]
pub unsafe fn gpio_is_valid(mut gpio: gpio_t) -> libc::c_int {
return (gpio as libc::c_int != GPIO_UNDEF) as libc::c_int;
}
#[inline]
pub unsafe fn _irq_debug_start_count() {
::core::ptr::write_volatile(
&mut (*(SysTick as *mut SysTick_Type)).VAL as *mut uint32_t,
0 as libc::c_int as uint32_t,
);
::core::ptr::write_volatile(
&mut (*(SysTick as *mut SysTick_Type)).LOAD as *mut uint32_t,
SysTick_LOAD_RELOAD_Msk as uint32_t,
);
::core::ptr::write_volatile(
&mut (*(SysTick as *mut SysTick_Type)).CTRL as *mut uint32_t,
(SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_ENABLE_Msk) as uint32_t,
);
}
pub const GPIO_UNDEF: libc::c_int = 255 as libc::c_int;
#[inline]
pub unsafe fn spi_transfer_u16_be(
mut bus: spi_t,
mut cs: spi_cs_t,
mut cont: bool,
mut host_number: uint16_t,
) -> uint16_t {
let send: uint16_t = host_number.swap_bytes();
let mut receive: uint16_t = 0;
spi_transfer_bytes(
bus,
cs,
cont,
&send as *const uint16_t as *const libc::c_void,
&mut receive as *mut uint16_t as *mut libc::c_void,
::core::mem::size_of::<uint16_t>() as libc::c_ulong,
);
return receive.swap_bytes();
}
#[inline]
pub unsafe fn bluetil_ad_add_flags(
mut ad: *mut bluetil_ad_t,
mut flags: uint8_t,
) -> libc::c_int {
return bluetil_ad_add(
ad,
BLE_GAP_AD_FLAGS as uint8_t,
&mut flags as *mut uint8_t as *const libc::c_void,
1 as libc::c_int as size_t,
);
}
pub const BLE_GAP_AD_FLAGS: libc::c_int = 0x1 as libc::c_int;
#[inline]
pub unsafe fn bluetil_ad_add_name(
mut ad: *mut bluetil_ad_t,
mut name: *const libc::c_char,
) -> libc::c_int {
return bluetil_ad_add(
ad,
BLE_GAP_AD_NAME as uint8_t,
name as *const libc::c_void,
strlen(name),
);
}
pub const BLE_GAP_AD_NAME: libc::c_int = 0x9 as libc::c_int;
#[inline]
pub unsafe fn bluetil_ad_init_with_flags(
mut ad: *mut bluetil_ad_t,
mut buf: *mut libc::c_void,
mut buf_len: size_t,
mut flags: uint8_t,
) -> libc::c_int {
bluetil_ad_init(ad, buf, 0 as libc::c_int as size_t, buf_len);
return bluetil_ad_add_flags(ad, flags);
}
#[inline]
pub unsafe fn ptrtag(
mut ptr: *mut libc::c_void,
mut tag: uint8_t,
) -> *mut libc::c_void {
let mut tmp: uintptr_t = ptr as uintptr_t;
if ((tag as libc::c_int) < 4 as libc::c_int
&& tmp & 0x3 as libc::c_int as libc::c_uint == 0) as libc::c_int as uintptr_t
as libc::c_long != 0
{} else {
_assert_panic();
};
return (tmp | tag as libc::c_uint) as *mut libc::c_void;
}
#[inline]
pub unsafe fn ptrtag_ptr(mut tagged_ptr: *mut libc::c_void) -> *mut libc::c_void {
let mut tagged: uintptr_t = tagged_ptr as uintptr_t;
let mask: uintptr_t = 0x3 as libc::c_int as uintptr_t;
return (tagged & !mask) as *mut libc::c_void;
}
#[inline]
pub unsafe fn ptrtag_tag(mut tagged_ptr: *mut libc::c_void) -> uint8_t {
let mut tagged: uintptr_t = tagged_ptr as uintptr_t;
return (tagged & 0x3 as libc::c_int as libc::c_uint) as uint8_t;
}
#[inline]
pub unsafe fn ztimer_acquire(mut clock: *mut ztimer_clock_t) -> bool {
return false_0 != 0;
}
#[inline]
pub unsafe fn ztimer_release(mut clock: *mut ztimer_clock_t) -> bool {
return false_0 != 0;
}
#[inline]
pub unsafe fn ztimer_now(mut clock: *mut ztimer_clock_t) -> ztimer_now_t {
if (*clock).max_value < UINT32_MAX {
return _ztimer_now_extend(clock)
} else {
return ((*(*clock).ops).now).expect("non-null function pointer")(clock)
};
}
#[inline]
pub unsafe fn cortexm_isr_end() {
if sched_context_switch_request != 0 {
thread_yield_higher();
}
}
#[inline]
pub unsafe fn ztimer_spin(
mut clock: *mut ztimer_clock_t,
mut duration: uint32_t,
) {
ztimer_acquire(clock);
let mut end: uint32_t = (ztimer_now(clock)).wrapping_add(duration);
while end.wrapping_sub(ztimer_now(clock)) <= duration {}
ztimer_release(clock);
}
#[inline]
pub unsafe fn ztimer_init_extend(mut clock: *mut ztimer_clock_t) {
if (*clock).max_value < UINT32_MAX {
((*(*clock).ops).set)
.expect(
"non-null function pointer",
)(clock, (*clock).max_value >> 1 as libc::c_int);
}
}
#[inline]
pub unsafe fn event_queues_init(
mut queues: *mut event_queue_t,
mut n_queues: size_t,
) {
if (!queues.is_null() && n_queues != 0) as libc::c_int as uintptr_t as libc::c_long
!= 0
{} else {
_assert_panic();
};
let mut me: *mut thread_t = thread_get_active();
let mut i: size_t = 0 as libc::c_int as size_t;
while i < n_queues {
memset(
&mut *queues.offset(i as isize) as *mut event_queue_t as *mut libc::c_void,
'\0' as i32,
::core::mem::size_of::<event_queue_t>() as libc::c_ulong,
);
let ref mut fresh34 = (*queues.offset(i as isize)).0.waiter;
*fresh34 = me;
i = i.wrapping_add(1);
i;
}
}
#[inline]
pub unsafe fn event_queue_init(mut queue: *mut event_queue_t) {
event_queues_init(queue, 1 as libc::c_int as size_t);
}
#[inline]
pub unsafe fn event_queues_init_detached(
mut queues: *mut event_queue_t,
mut n_queues: size_t,
) {
if queues as uintptr_t as libc::c_long != 0 {} else {
_assert_panic();
};
let mut i: size_t = 0 as libc::c_int as size_t;
while i < n_queues {
memset(
&mut *queues.offset(i as isize) as *mut event_queue_t as *mut libc::c_void,
'\0' as i32,
::core::mem::size_of::<event_queue_t>() as libc::c_ulong,
);
i = i.wrapping_add(1);
i;
}
}
#[inline]
pub unsafe fn event_queue_init_detached(mut queue: *mut event_queue_t) {
event_queues_init_detached(queue, 1 as libc::c_int as size_t);
}
#[inline]
pub unsafe fn event_queues_claim(
mut queues: *mut event_queue_t,
mut n_queues: size_t,
) {
if queues as uintptr_t as libc::c_long != 0 {} else {
_assert_panic();
};
let mut me: *mut thread_t = thread_get_active();
let mut i: size_t = 0 as libc::c_int as size_t;
while i < n_queues {
if ((*queues.offset(i as isize)).0.waiter
== 0 as *mut libc::c_void as *mut thread_t) as libc::c_int as uintptr_t
as libc::c_long != 0
{} else {
_assert_panic();
};
let ref mut fresh35 = (*queues.offset(i as isize)).0.waiter;
*fresh35 = me;
i = i.wrapping_add(1);
i;
}
}
#[inline]
pub unsafe fn event_queue_claim(mut queue: *mut event_queue_t) {
event_queues_claim(queue, 1 as libc::c_int as size_t);
}
#[inline]
pub unsafe fn event_wait(mut queue: *mut event_queue_t) -> *mut event_t {
return event_wait_multi(queue, 1 as libc::c_int as size_t);
}
#[inline]
pub unsafe fn event_loop_multi(
mut queues: *mut event_queue_t,
mut n_queues: size_t,
) {
let mut event: *mut event_t = 0 as *mut event_t;
loop {
event = event_wait_multi(queues, n_queues);
if event.is_null() {
break;
}
((*event).handler).expect("non-null function pointer")(event);
};
}
#[inline]
pub unsafe fn event_loop(mut queue: *mut event_queue_t) {
event_loop_multi(queue, 1 as libc::c_int as size_t);
}
#[inline]
pub unsafe fn event_callback_post(
mut queue: *mut event_queue_t,
mut event: *mut event_callback_t,
) {
if ::core::mem::transmute::<
Option::<unsafe extern "C" fn(*mut libc::c_void) -> ()>,
uintptr_t,
>((*event).callback) as libc::c_long != 0
{} else {
_assert_panic();
};
event_post(queue, &mut (*event).super_0);
}
#[inline]
pub unsafe fn event_callback_oneshot(
mut event: *mut event_callback_t,
mut queue: *mut event_queue_t,
mut callback: Option::<unsafe extern "C" fn(*mut libc::c_void) -> ()>,
mut arg: *mut libc::c_void,
) {
event_callback_init(event, callback, arg);
event_post(queue, &mut (*event).super_0);
}
#[inline]
pub unsafe fn event_timeout_is_pending(
mut event_timeout: *const event_timeout_t,
) -> bool {
if ((*event_timeout).clock).is_null() || ((*event_timeout).queue).is_null()
|| ((*event_timeout).event).is_null()
{
return false_0 != 0;
}
return ztimer_is_set((*event_timeout).clock, &(*event_timeout).timer) != 0
|| event_is_queued((*event_timeout).queue, (*event_timeout).event) as libc::c_int
!= 0;
}
#[inline]
pub unsafe fn cpu_jump_to_image(mut image_address: uint32_t) {
__set_MSP(*(image_address as *mut uint32_t));
image_address = (image_address as libc::c_uint)
.wrapping_add(4 as libc::c_int as libc::c_uint) as uint32_t as uint32_t;
let mut destination_address: uint32_t = *(image_address as *mut uint32_t);
destination_address |= 0x1 as libc::c_int as libc::c_uint;
asm!("BX {0}", inlateout(reg) destination_address => _, options(preserves_flags));
}
#[inline]
pub unsafe fn unaligned_get_u16(mut ptr: *const libc::c_void) -> uint16_t {
let mut tmp: *const uint16_una_t = ptr as *const uint16_una_t;
return (*tmp).val;
}
#[inline]
pub unsafe fn unaligned_get_u32(mut ptr: *const libc::c_void) -> uint32_t {
let mut tmp: *const uint32_una_t = ptr as *const uint32_una_t;
return (*tmp).val;
}
#[inline]
pub unsafe fn unaligned_get_u64(mut ptr: *const libc::c_void) -> uint64_t {
let mut tmp: *const uint64_una_t = ptr as *const uint64_una_t;
return (*tmp).val;
}
#[inline]
pub unsafe fn byteorder_ltohs(mut v: le_uint16_t) -> uint16_t {
return v.u16_0;
}
#[inline]
pub unsafe fn byteorder_ltohl(mut v: le_uint32_t) -> uint32_t {
return v.u32_0;
}
#[inline]
pub unsafe fn byteorder_ltohll(mut v: le_uint64_t) -> uint64_t {
return v.u64_0;
}
#[inline]
pub unsafe fn byteorder_ltobs(mut v: le_uint16_t) -> be_uint16_t {
let mut result: be_uint16_t = be_uint16_t {
u16_0: byteorder_swaps(v.u16_0),
};
return result;
}
#[inline]
pub unsafe fn byteorder_swaps(mut v: uint16_t) -> uint16_t {
return v.swap_bytes();
}
#[inline]
pub unsafe fn byteorder_ltobl(mut v: le_uint32_t) -> be_uint32_t {
let mut result: be_uint32_t = be_uint32_t {
u32_0: byteorder_swapl(v.u32_0),
};
return result;
}
#[inline]
pub unsafe fn byteorder_swapl(mut v: uint32_t) -> uint32_t {
return v.swap_bytes();
}
#[inline]
pub unsafe fn byteorder_ltobll(mut v: le_uint64_t) -> be_uint64_t {
let mut result: be_uint64_t = be_uint64_t {
u64_0: byteorder_swapll(v.u64_0),
};
return result;
}
#[inline]
pub unsafe fn byteorder_swapll(mut v: uint64_t) -> uint64_t {
return v.swap_bytes();
}
#[inline]
pub unsafe fn byteorder_btols(mut v: be_uint16_t) -> le_uint16_t {
let mut result: le_uint16_t = le_uint16_t {
u16_0: byteorder_swaps(v.u16_0),
};
return result;
}
#[inline]
pub unsafe fn byteorder_btoll(mut v: be_uint32_t) -> le_uint32_t {
let mut result: le_uint32_t = le_uint32_t {
u32_0: byteorder_swapl(v.u32_0),
};
return result;
}
#[inline]
pub unsafe fn byteorder_btolll(mut v: be_uint64_t) -> le_uint64_t {
let mut result: le_uint64_t = le_uint64_t {
u64_0: byteorder_swapll(v.u64_0),
};
return result;
}
#[inline]
pub unsafe fn byteorder_htols(mut v: uint16_t) -> le_uint16_t {
let mut result: le_uint16_t = le_uint16_t { u16_0: v };
return result;
}
#[inline]
pub unsafe fn byteorder_htoll(mut v: uint32_t) -> le_uint32_t {
let mut result: le_uint32_t = le_uint32_t { u32_0: v };
return result;
}
#[inline]
pub unsafe fn byteorder_htolll(mut v: uint64_t) -> le_uint64_t {
let mut result: le_uint64_t = le_uint64_t { u64_0: v };
return result;
}
#[inline]
pub unsafe fn byteorder_htons(mut v: uint16_t) -> network_uint16_t {
let mut result: network_uint16_t = be_uint16_t {
u16_0: v.swap_bytes(),
};
return result;
}
#[inline]
pub unsafe fn byteorder_htonl(mut v: uint32_t) -> network_uint32_t {
let mut result: network_uint32_t = be_uint32_t {
u32_0: v.swap_bytes(),
};
return result;
}
#[inline]
pub unsafe fn byteorder_htonll(mut v: uint64_t) -> network_uint64_t {
let mut result: network_uint64_t = be_uint64_t {
u64_0: v.swap_bytes(),
};
return result;
}
#[inline]
pub unsafe fn byteorder_ntohs(mut v: network_uint16_t) -> uint16_t {
return (v.u16_0).swap_bytes();
}
#[inline]
pub unsafe fn byteorder_ntohl(mut v: network_uint32_t) -> uint32_t {
return (v.u32_0).swap_bytes();
}
#[inline]
pub unsafe fn byteorder_ntohll(mut v: network_uint64_t) -> uint64_t {
return (v.u64_0).swap_bytes();
}
#[inline]
pub unsafe fn byteorder_bebuftohs(mut buf: *const uint8_t) -> uint16_t {
return (unaligned_get_u16(buf as *const libc::c_void)).swap_bytes();
}
#[inline]
pub unsafe fn byteorder_bebuftohl(mut buf: *const uint8_t) -> uint32_t {
return (unaligned_get_u32(buf as *const libc::c_void)).swap_bytes();
}
#[inline]
pub unsafe fn byteorder_bebuftohll(mut buf: *const uint8_t) -> uint64_t {
return (unaligned_get_u64(buf as *const libc::c_void)).swap_bytes();
}
#[inline]
pub unsafe fn byteorder_htobebufs(mut buf: *mut uint8_t, mut val: uint16_t) {
val = val.swap_bytes();
memcpy(
buf as *mut libc::c_void,
&mut val as *mut uint16_t as *const libc::c_void,
::core::mem::size_of::<uint16_t>() as libc::c_ulong,
);
}
#[inline]
pub unsafe fn byteorder_htobebufl(mut buf: *mut uint8_t, mut val: uint32_t) {
val = val.swap_bytes();
memcpy(
buf as *mut libc::c_void,
&mut val as *mut uint32_t as *const libc::c_void,
::core::mem::size_of::<uint32_t>() as libc::c_ulong,
);
}
#[inline]
pub unsafe fn byteorder_htobebufll(mut buf: *mut uint8_t, mut val: uint64_t) {
val = val.swap_bytes();
memcpy(
buf as *mut libc::c_void,
&mut val as *mut uint64_t as *const libc::c_void,
::core::mem::size_of::<uint64_t>() as libc::c_ulong,
);
}
#[inline]
pub unsafe fn htons(mut v: uint16_t) -> uint16_t {
return v.swap_bytes();
}
#[inline]
pub unsafe fn htonl(mut v: uint32_t) -> uint32_t {
return v.swap_bytes();
}
#[inline]
pub unsafe fn htonll(mut v: uint64_t) -> uint64_t {
return v.swap_bytes();
}
#[inline]
pub unsafe fn ntohs(mut v: uint16_t) -> uint16_t {
return v.swap_bytes();
}
#[inline]
pub unsafe fn ntohl(mut v: uint32_t) -> uint32_t {
return v.swap_bytes();
}
#[inline]
pub unsafe fn ntohll(mut v: uint64_t) -> uint64_t {
return v.swap_bytes();
}
#[inline]
pub unsafe fn byteorder_lebuftohs(mut buf: *const uint8_t) -> uint16_t {
return unaligned_get_u16(buf as *const libc::c_void);
}
#[inline]
pub unsafe fn byteorder_lebuftohl(mut buf: *const uint8_t) -> uint32_t {
return unaligned_get_u32(buf as *const libc::c_void);
}
#[inline]
pub unsafe fn byteorder_lebuftohll(mut buf: *const uint8_t) -> uint64_t {
return unaligned_get_u64(buf as *const libc::c_void);
}
#[inline]
pub unsafe fn byteorder_htolebufs(mut buf: *mut uint8_t, mut val: uint16_t) {
val = val;
memcpy(
buf as *mut libc::c_void,
&mut val as *mut uint16_t as *const libc::c_void,
::core::mem::size_of::<uint16_t>() as libc::c_ulong,
);
}
#[inline]
pub unsafe fn byteorder_htolebufl(mut buf: *mut uint8_t, mut val: uint32_t) {
val = val;
memcpy(
buf as *mut libc::c_void,
&mut val as *mut uint32_t as *const libc::c_void,
::core::mem::size_of::<uint32_t>() as libc::c_ulong,
);
}
#[inline]
pub unsafe fn byteorder_htolebufll(mut buf: *mut uint8_t, mut val: uint64_t) {
val = val;
memcpy(
buf as *mut libc::c_void,
&mut val as *mut uint64_t as *const libc::c_void,
::core::mem::size_of::<uint64_t>() as libc::c_ulong,
);
}
#[inline]
pub unsafe fn ipv4_addr_equal(
mut a: *const ipv4_addr_t,
mut b: *const ipv4_addr_t,
) -> bool {
return (*a).u32_0.u32_0 == (*b).u32_0.u32_0;
}
#[inline]
pub unsafe fn ipv4_addr_is_multicast(mut addr: *const ipv4_addr_t) -> bool {
return (*addr).u8_0[0 as libc::c_int as usize] as libc::c_int >= 0xe0 as libc::c_int
&& (*addr).u8_0[0 as libc::c_int as usize] as libc::c_int <= 0xef as libc::c_int;
}
#[inline]
pub unsafe fn ipv6_addr_is_unspecified(mut addr: *const ipv6_addr_t) -> bool {
return memcmp(
addr as *const libc::c_void,
&ipv6_addr_unspecified as *const ipv6_addr_t as *const libc::c_void,
::core::mem::size_of::<ipv6_addr_t>() as libc::c_ulong,
) == 0 as libc::c_int;
}
#[inline]
pub unsafe fn ipv6_addr_is_loopback(mut addr: *const ipv6_addr_t) -> bool {
return memcmp(
addr as *const libc::c_void,
&ipv6_addr_loopback as *const ipv6_addr_t as *const libc::c_void,
::core::mem::size_of::<ipv6_addr_t>() as libc::c_ulong,
) == 0 as libc::c_int;
}
#[inline]
pub unsafe fn ipv6_addr_is_ipv4_compat(mut addr: *const ipv6_addr_t) -> bool {
return memcmp(
addr as *const libc::c_void,
&ipv6_addr_unspecified as *const ipv6_addr_t as *const libc::c_void,
(::core::mem::size_of::<ipv6_addr_t>() as libc::c_ulong)
.wrapping_sub(::core::mem::size_of::<ipv4_addr_t>() as libc::c_ulong),
) == 0 as libc::c_int;
}
#[inline]
pub unsafe fn ipv6_addr_is_ipv4_mapped(mut addr: *const ipv6_addr_t) -> bool {
return memcmp(
addr as *const libc::c_void,
&ipv6_addr_unspecified as *const ipv6_addr_t as *const libc::c_void,
(::core::mem::size_of::<ipv6_addr_t>() as libc::c_ulong)
.wrapping_sub(::core::mem::size_of::<ipv4_addr_t>() as libc::c_ulong)
.wrapping_sub(2 as libc::c_int as libc::c_uint),
) == 0 as libc::c_int
&& (*addr).u16_0[5 as libc::c_int as usize].u16_0 as libc::c_int
== 0xffff as libc::c_int;
}
#[inline]
pub unsafe fn ipv6_addr_is_multicast(mut addr: *const ipv6_addr_t) -> bool {
return (*addr).u8_0[0 as libc::c_int as usize] as libc::c_int == 0xff as libc::c_int;
}
#[inline]
pub unsafe fn ipv6_addr_is_link_local(mut addr: *const ipv6_addr_t) -> bool {
return memcmp(
addr as *const libc::c_void,
&ipv6_addr_link_local_prefix as *const ipv6_addr_t as *const libc::c_void,
::core::mem::size_of::<network_uint64_t>() as libc::c_ulong,
) == 0 as libc::c_int
|| ipv6_addr_is_multicast(addr) as libc::c_int != 0
&& (*addr).u8_0[1 as libc::c_int as usize] as libc::c_int
& 0xf as libc::c_int == IPV6_ADDR_MCAST_SCP_LINK_LOCAL;
}
pub const IPV6_ADDR_MCAST_SCP_LINK_LOCAL: libc::c_int = 0x2 as libc::c_int;
#[inline]
pub unsafe fn ipv6_addr_is_site_local(mut addr: *const ipv6_addr_t) -> bool {
return byteorder_ntohs((*addr).u16_0[0 as libc::c_int as usize]) as libc::c_int
& 0xffc0 as libc::c_int == IPV6_ADDR_SITE_LOCAL_PREFIX
|| ipv6_addr_is_multicast(addr) as libc::c_int != 0
&& (*addr).u8_0[1 as libc::c_int as usize] as libc::c_int
& 0xf as libc::c_int == IPV6_ADDR_MCAST_SCP_SITE_LOCAL;
}
pub const IPV6_ADDR_MCAST_SCP_SITE_LOCAL: libc::c_int = 0x5 as libc::c_int;
pub const IPV6_ADDR_SITE_LOCAL_PREFIX: libc::c_int = 0xfec0 as libc::c_int;
#[inline]
pub unsafe fn ipv6_addr_is_unique_local_unicast(
mut addr: *const ipv6_addr_t,
) -> bool {
return (*addr).u8_0[0 as libc::c_int as usize] as libc::c_int == 0xfc as libc::c_int
|| (*addr).u8_0[0 as libc::c_int as usize] as libc::c_int == 0xfd as libc::c_int;
}
#[inline]
pub unsafe fn ipv6_addr_is_global(mut addr: *const ipv6_addr_t) -> bool {
if ipv6_addr_is_multicast(addr) {
return (*addr).u8_0[1 as libc::c_int as usize] as libc::c_int
& 0xf as libc::c_int == IPV6_ADDR_MCAST_SCP_GLOBAL
} else {
return !(ipv6_addr_is_link_local(addr) as libc::c_int != 0
|| ipv6_addr_is_unspecified(addr) as libc::c_int != 0
|| ipv6_addr_is_loopback(addr) as libc::c_int != 0)
};
}
pub const IPV6_ADDR_MCAST_SCP_GLOBAL: libc::c_int = 0xe as libc::c_int;
#[inline]
pub unsafe fn ipv6_addr_is_solicited_node(mut addr: *const ipv6_addr_t) -> bool {
return memcmp(
addr as *const libc::c_void,
&ipv6_addr_solicited_node_prefix as *const ipv6_addr_t as *const libc::c_void,
(::core::mem::size_of::<ipv6_addr_t>() as libc::c_ulong)
.wrapping_sub(3 as libc::c_int as libc::c_uint),
) == 0 as libc::c_int;
}
#[inline]
pub unsafe fn ipv6_addr_init(
mut out: *mut ipv6_addr_t,
mut prefix: uint64_t,
mut iid: uint64_t,
) {
(*out).u64_0[0 as libc::c_int as usize] = byteorder_htonll(prefix);
(*out).u64_0[1 as libc::c_int as usize] = byteorder_htonll(iid);
}
#[inline]
pub unsafe fn ipv6_addr_set_unspecified(mut addr: *mut ipv6_addr_t) {
memset(
addr as *mut libc::c_void,
0 as libc::c_int,
::core::mem::size_of::<ipv6_addr_t>() as libc::c_ulong,
);
}
#[inline]
pub unsafe fn ipv6_addr_set_loopback(mut addr: *mut ipv6_addr_t) {
memset(
addr as *mut libc::c_void,
0 as libc::c_int,
::core::mem::size_of::<ipv6_addr_t>() as libc::c_ulong,
);
(*addr).u8_0[15 as libc::c_int as usize] = 1 as libc::c_int as uint8_t;
}
#[inline]
pub unsafe fn ipv6_addr_set_link_local_prefix(mut addr: *mut ipv6_addr_t) {
memcpy(
addr as *mut libc::c_void,
&ipv6_addr_link_local_prefix as *const ipv6_addr_t as *const libc::c_void,
::core::mem::size_of::<network_uint64_t>() as libc::c_ulong,
);
}
#[inline]
pub unsafe fn ipv6_addr_set_iid(mut addr: *mut ipv6_addr_t, mut iid: uint64_t) {
(*addr).u64_0[1 as libc::c_int as usize] = byteorder_htonll(iid);
}
#[inline]
pub unsafe fn ipv6_addr_set_aiid(
mut addr: *mut ipv6_addr_t,
mut iid: *mut uint8_t,
) {
memcpy(
&mut *((*addr).u64_0).as_mut_ptr().offset(1 as libc::c_int as isize)
as *mut network_uint64_t as *mut libc::c_void,
iid as *const libc::c_void,
::core::mem::size_of::<network_uint64_t>() as libc::c_ulong,
);
}
#[inline]
pub unsafe fn ipv6_addr_set_multicast(
mut addr: *mut ipv6_addr_t,
mut flags: libc::c_uint,
mut scope: libc::c_uint,
) {
(*addr).u8_0[0 as libc::c_int as usize] = 0xff as libc::c_int as uint8_t;
(*addr)
.u8_0[1 as libc::c_int
as usize] = ((flags as uint8_t as libc::c_int) << 4 as libc::c_int
| scope as uint8_t as libc::c_int & 0xf as libc::c_int) as uint8_t;
}
#[inline]
pub unsafe fn ipv6_addr_set_all_nodes_multicast(
mut addr: *mut ipv6_addr_t,
mut scope: libc::c_uint,
) {
memcpy(
addr as *mut libc::c_void,
&ipv6_addr_all_nodes_if_local as *const ipv6_addr_t as *const libc::c_void,
::core::mem::size_of::<ipv6_addr_t>() as libc::c_ulong,
);
(*addr).u8_0[1 as libc::c_int as usize] = scope as uint8_t;
}
#[inline]
pub unsafe fn ipv6_addr_set_all_routers_multicast(
mut addr: *mut ipv6_addr_t,
mut scope: libc::c_uint,
) {
memcpy(
addr as *mut libc::c_void,
&ipv6_addr_all_routers_if_local as *const ipv6_addr_t as *const libc::c_void,
::core::mem::size_of::<ipv6_addr_t>() as libc::c_ulong,
);
(*addr).u8_0[1 as libc::c_int as usize] = scope as uint8_t;
}
#[inline]
pub unsafe fn ipv6_addr_set_solicited_nodes(
mut out: *mut ipv6_addr_t,
mut in_0: *const ipv6_addr_t,
) {
(*out)
.u64_0[0 as libc::c_int
as usize] = byteorder_htonll(0xff02000000000000 as libc::c_ulonglong);
(*out)
.u32_0[2 as libc::c_int
as usize] = byteorder_htonl(1 as libc::c_int as uint32_t);
(*out).u8_0[12 as libc::c_int as usize] = 0xff as libc::c_int as uint8_t;
(*out).u8_0[13 as libc::c_int as usize] = (*in_0).u8_0[13 as libc::c_int as usize];
(*out).u16_0[7 as libc::c_int as usize] = (*in_0).u16_0[7 as libc::c_int as usize];
}
#[inline]
pub unsafe fn ipv6_addr_split_prefix(
mut addr_str: *mut libc::c_char,
) -> libc::c_int {
return ipv6_addr_split_int(addr_str, '/' as i32 as libc::c_char, 128 as libc::c_int);
}
#[inline]
pub unsafe fn ipv6_addr_split_iface(
mut addr_str: *mut libc::c_char,
) -> *mut libc::c_char {
return ipv6_addr_split_str(addr_str, '%' as i32 as libc::c_char);
}
#[inline]
pub unsafe fn sock_udp_recv(
mut sock: *mut sock_udp_t,
mut data: *mut libc::c_void,
mut max_len: size_t,
mut timeout: uint32_t,
mut remote: *mut sock_udp_ep_t,
) -> ssize_t {
return sock_udp_recv_aux(
sock,
data,
max_len,
timeout,
remote,
NULL_1 as *mut sock_udp_aux_rx_t,
);
}
#[inline]
pub unsafe fn cpu_get_image_baseaddr() -> uint32_t {
return (*(SCB as *mut SCB_Type)).VTOR;
}
#[inline]
pub unsafe fn sock_udp_recv_buf(
mut sock: *mut sock_udp_t,
mut data: *mut *mut libc::c_void,
mut buf_ctx: *mut *mut libc::c_void,
mut timeout: uint32_t,
mut remote: *mut sock_udp_ep_t,
) -> ssize_t {
return sock_udp_recv_buf_aux(
sock,
data,
buf_ctx,
timeout,
remote,
NULL_1 as *mut sock_udp_aux_rx_t,
);
}
#[inline]
pub unsafe fn sock_udp_send_aux(
mut sock: *mut sock_udp_t,
mut data: *const libc::c_void,
mut len: size_t,
mut remote: *const sock_udp_ep_t,
mut aux: *mut sock_udp_aux_tx_t,
) -> ssize_t {
let snip: iolist_t = {
let mut init = iolist {
iol_next: NULL_1 as *mut iolist_t,
iol_base: data as *mut libc::c_void,
iol_len: len,
};
init
};
return sock_udp_sendv_aux(sock, &snip, remote, aux);
}
#[inline]
pub unsafe fn sock_udp_send(
mut sock: *mut sock_udp_t,
mut data: *const libc::c_void,
mut len: size_t,
mut remote: *const sock_udp_ep_t,
) -> ssize_t {
return sock_udp_send_aux(sock, data, len, remote, NULL_1 as *mut sock_udp_aux_tx_t);
}
#[inline]
pub unsafe fn sock_udp_sendv(
mut sock: *mut sock_udp_t,
mut snips: *const iolist_t,
mut remote: *const sock_udp_ep_t,
) -> ssize_t {
return sock_udp_sendv_aux(sock, snips, remote, NULL_1 as *mut sock_udp_aux_tx_t);
}
#[inline]
pub unsafe fn sock_udp_ep_is_multicast(mut ep: *const sock_udp_ep_t) -> bool {
match (*ep).family {
AF_INET6_0 => {
return ipv6_addr_is_multicast(
&(*ep).addr.ipv6 as *const [uint8_t; 16] as *const ipv6_addr_t,
);
}
_ => {
if 0 as libc::c_int as uintptr_t as libc::c_long != 0 {} else {
_assert_panic();
};
}
}
return false_0 != 0;
}
pub const AF_INET6_0: libc::c_int = AF_INET6 as libc::c_int;
#[inline]
pub unsafe fn sock_udp_ep_is_v6(mut ep: *const sock_udp_ep_t) -> bool {
return true_0 != 0;
}
#[inline]
pub unsafe fn mbox_init(
mut mbox: *mut mbox_t,
mut queue: *mut msg_t,
mut queue_size: libc::c_uint,
) {
let mut m: mbox_t = {
let mut init = mbox_t {
readers: {
let mut init = list_node {
next: 0 as *mut list_node,
};
init
},
writers: {
let mut init = list_node {
next: 0 as *mut list_node,
};
init
},
cib: {
let mut init = cib_t {
read_count: 0 as libc::c_int as libc::c_uint,
write_count: 0 as libc::c_int as libc::c_uint,
mask: queue_size.wrapping_sub(1 as libc::c_int as libc::c_uint),
};
init
},
msg_array: queue,
};
init
};
*mbox = m;
}
#[inline]
pub unsafe fn mbox_put(mut mbox: *mut mbox_t, mut msg: *mut msg_t) {
_mbox_put(mbox, msg, BLOCKING as libc::c_int);
}
#[inline]
pub unsafe fn mbox_try_put(
mut mbox: *mut mbox_t,
mut msg: *mut msg_t,
) -> libc::c_int {
return _mbox_put(mbox, msg, NON_BLOCKING as libc::c_int);
}
#[inline]
pub unsafe fn mbox_get(mut mbox: *mut mbox_t, mut msg: *mut msg_t) {
_mbox_get(mbox, msg, BLOCKING as libc::c_int);
}
#[inline]
pub unsafe fn mbox_try_get(
mut mbox: *mut mbox_t,
mut msg: *mut msg_t,
) -> libc::c_int {
return _mbox_get(mbox, msg, NON_BLOCKING as libc::c_int);
}
#[inline]
pub unsafe fn mbox_size(mut mbox: *mut mbox_t) -> size_t {
return if (*mbox).cib.mask != 0 {
((*mbox).cib.mask).wrapping_add(1 as libc::c_int as libc::c_uint)
} else {
0 as libc::c_int as libc::c_uint
};
}
#[inline]
pub unsafe fn mbox_avail(mut mbox: *mut mbox_t) -> size_t {
return cib_avail(&mut (*mbox).cib);
}
#[inline]
pub unsafe fn mbox_unset(mut mbox: *mut mbox_t) {
(*mbox).msg_array = NULL_1 as *mut msg_t;
(*mbox).cib.mask = 0 as libc::c_int as libc::c_uint;
}
#[inline]
pub unsafe fn gnrc_nettype_from_ethertype(
mut type_0: uint16_t,
) -> gnrc_nettype_t {
match type_0 as libc::c_int {
ETHERTYPE_IPV6 => return GNRC_NETTYPE_IPV6,
_ => return GNRC_NETTYPE_UNDEF,
};
}
pub const ETHERTYPE_IPV6: libc::c_int = 0x86dd as libc::c_int;
#[inline]
pub unsafe fn gnrc_nettype_to_ethertype(mut type_0: gnrc_nettype_t) -> uint16_t {
match type_0 as libc::c_int {
1 => return ETHERTYPE_IPV6 as uint16_t,
_ => return ETHERTYPE_UNKNOWN as uint16_t,
};
}
pub const ETHERTYPE_UNKNOWN: libc::c_int = 0xffff as libc::c_int;
#[inline]
pub unsafe fn gnrc_nettype_from_protnum(mut num: uint8_t) -> gnrc_nettype_t {
match num as libc::c_int {
PROTNUM_ICMPV6 => return GNRC_NETTYPE_ICMPV6,
PROTNUM_IPV6 => return GNRC_NETTYPE_IPV6,
PROTNUM_TCP => return GNRC_NETTYPE_TCP,
PROTNUM_UDP => return GNRC_NETTYPE_UDP,
_ => return GNRC_NETTYPE_UNDEF,
};
}
pub const PROTNUM_UDP: libc::c_int = 17 as libc::c_int;
pub const PROTNUM_TCP: libc::c_int = 6 as libc::c_int;
pub const PROTNUM_IPV6: libc::c_int = 41 as libc::c_int;
pub const PROTNUM_ICMPV6: libc::c_int = 58;
#[inline]
pub unsafe fn gnrc_nettype_to_protnum(mut type_0: gnrc_nettype_t) -> uint8_t {
match type_0 as libc::c_int {
1 => return PROTNUM_IPV6 as uint8_t,
2 => return PROTNUM_ICMPV6 as uint8_t,
3 => return PROTNUM_TCP as uint8_t,
4 => return PROTNUM_UDP as uint8_t,
_ => return PROTNUM_RESERVED as uint8_t,
};
}
pub const PROTNUM_RESERVED: libc::c_int = 255 as libc::c_int;
#[inline]
pub unsafe fn gnrc_pkt_prev_snip(
mut pkt: *mut gnrc_pktsnip_t,
mut snip: *mut gnrc_pktsnip_t,
) -> *mut gnrc_pktsnip_t {
while !pkt.is_null() && (*pkt).next != snip {
pkt = (*pkt).next;
}
return pkt;
}
#[inline]
pub unsafe fn gnrc_pkt_len(mut pkt: *const gnrc_pktsnip_t) -> size_t {
let mut len: size_t = 0 as libc::c_int as size_t;
while !pkt.is_null() {
len = (len as libc::c_uint).wrapping_add((*pkt).size) as size_t as size_t;
pkt = (*pkt).next;
}
return len;
}
#[inline]
pub unsafe fn gnrc_pkt_append(
mut pkt: *mut gnrc_pktsnip_t,
mut snip: *mut gnrc_pktsnip_t,
) -> *mut gnrc_pktsnip_t {
let mut last: *mut gnrc_pktsnip_t = gnrc_pkt_prev_snip(
pkt,
NULL_1 as *mut gnrc_pktsnip_t,
);
if !last.is_null() {
(*last).next = snip;
} else {
pkt = snip;
}
return pkt;
}
#[inline]
pub unsafe fn gnrc_pkt_prepend(
mut pkt: *mut gnrc_pktsnip_t,
mut snip: *mut gnrc_pktsnip_t,
) -> *mut gnrc_pktsnip_t {
(*snip).next = pkt;
return snip;
}
#[inline]
pub unsafe fn gnrc_pkt_delete(
mut pkt: *mut gnrc_pktsnip_t,
mut snip: *mut gnrc_pktsnip_t,
) -> *mut gnrc_pktsnip_t {
if pkt == snip {
return (*pkt).next;
}
if snip.is_null() {
return pkt;
}
let mut i: *mut gnrc_pktsnip_t = pkt;
while !i.is_null() {
if (*i).next == snip {
(*i).next = (*snip).next;
return pkt;
}
i = (*i).next;
}
return pkt;
}
#[inline]
pub unsafe fn gnrc_pkt_len_upto(
mut pkt: *const gnrc_pktsnip_t,
mut type_0: gnrc_nettype_t,
) -> size_t {
let mut len: size_t = 0 as libc::c_int as size_t;
while !pkt.is_null() {
len = (len as libc::c_uint).wrapping_add((*pkt).size) as size_t as size_t;
if (*pkt).type_0 as libc::c_int == type_0 as libc::c_int {
break;
}
pkt = (*pkt).next;
}
return len;
}
#[inline]
pub unsafe fn gnrc_pkt_count(mut pkt: *const gnrc_pktsnip_t) -> size_t {
let mut count: size_t = 0 as libc::c_int as size_t;
while !pkt.is_null() {
count = count.wrapping_add(1);
count;
pkt = (*pkt).next;
}
return count;
}
#[inline]
pub unsafe fn gnrc_netapi_send(
mut pid: kernel_pid_t,
mut pkt: *mut gnrc_pktsnip_t,
) -> libc::c_int {
return _gnrc_netapi_send_recv(pid, pkt, GNRC_NETAPI_MSG_TYPE_SND as uint16_t);
}
pub const GNRC_NETAPI_MSG_TYPE_SND: libc::c_int = 0x202 as libc::c_int;
#[inline]
pub unsafe fn gnrc_netapi_dispatch_send(
mut type_0: gnrc_nettype_t,
mut demux_ctx: uint32_t,
mut pkt: *mut gnrc_pktsnip_t,
) -> libc::c_int {
return gnrc_netapi_dispatch(
type_0,
demux_ctx,
GNRC_NETAPI_MSG_TYPE_SND as uint16_t,
pkt,
);
}
#[inline]
pub unsafe fn gnrc_netapi_receive(
mut pid: kernel_pid_t,
mut pkt: *mut gnrc_pktsnip_t,
) -> libc::c_int {
return _gnrc_netapi_send_recv(pid, pkt, GNRC_NETAPI_MSG_TYPE_RCV as uint16_t);
}
pub const GNRC_NETAPI_MSG_TYPE_RCV: libc::c_int = 0x201 as libc::c_int;
#[inline]
pub unsafe fn gnrc_netapi_dispatch_receive(
mut type_0: gnrc_nettype_t,
mut demux_ctx: uint32_t,
mut pkt: *mut gnrc_pktsnip_t,
) -> libc::c_int {
return gnrc_netapi_dispatch(
type_0,
demux_ctx,
GNRC_NETAPI_MSG_TYPE_RCV as uint16_t,
pkt,
);
}
#[inline]
pub unsafe fn gnrc_netapi_get(
mut pid: kernel_pid_t,
mut opt: netopt_t,
mut context: uint16_t,
mut data: *mut libc::c_void,
mut max_len: size_t,
) -> libc::c_int {
return _gnrc_netapi_get_set(
pid,
opt,
context,
data,
max_len,
GNRC_NETAPI_MSG_TYPE_GET as uint16_t,
);
}
pub const GNRC_NETAPI_MSG_TYPE_GET: libc::c_int = 0x204 as libc::c_int;
#[inline]
pub unsafe fn gnrc_netapi_set(
mut pid: kernel_pid_t,
mut opt: netopt_t,
mut context: uint16_t,
mut data: *const libc::c_void,
mut data_len: size_t,
) -> libc::c_int {
return _gnrc_netapi_get_set(
pid,
opt,
context,
data as *mut libc::c_void,
data_len,
GNRC_NETAPI_MSG_TYPE_SET as uint16_t,
);
}
pub const GNRC_NETAPI_MSG_TYPE_SET: libc::c_int = 0x203 as libc::c_int;
#[inline]
pub unsafe fn gnrc_netreg_entry_init_pid(
mut entry: *mut gnrc_netreg_entry_t,
mut demux_ctx: uint32_t,
mut pid: kernel_pid_t,
) {
(*entry).next = NULL_1 as *mut gnrc_netreg_entry;
(*entry).demux_ctx = demux_ctx;
(*entry).type_0 = GNRC_NETREG_TYPE_DEFAULT;
(*entry).target.pid = pid;
}
#[inline]
pub unsafe fn gnrc_netreg_entry_init_mbox(
mut entry: *mut gnrc_netreg_entry_t,
mut demux_ctx: uint32_t,
mut mbox: *mut mbox_t,
) {
(*entry).next = NULL_1 as *mut gnrc_netreg_entry;
(*entry).demux_ctx = demux_ctx;
(*entry).type_0 = GNRC_NETREG_TYPE_MBOX;
(*entry).target.mbox = mbox;
}
#[inline]
pub unsafe fn gnrc_netreg_entry_init_cb(
mut entry: *mut gnrc_netreg_entry_t,
mut demux_ctx: uint32_t,
mut cbd: *mut gnrc_netreg_entry_cbd_t,
) {
(*entry).next = NULL_1 as *mut gnrc_netreg_entry;
(*entry).demux_ctx = demux_ctx;
(*entry).type_0 = GNRC_NETREG_TYPE_CB;
(*entry).target.cbd = cbd;
}
#[inline]
pub unsafe fn dhcpv6_client_conf_addr(
mut netif: libc::c_uint,
mut addr: *const ipv6_addr_t,
mut valid: uint32_t,
mut pref: uint32_t,
) {
dhcpv6_client_conf_prefix(
netif,
addr,
IPV6_ADDR_BIT_LEN as libc::c_uint,
valid,
pref,
);
}
pub const IPV6_ADDR_BIT_LEN: libc::c_int = 128 as libc::c_int;
#[inline]
pub unsafe fn dhcpv6_client_addr_valid_until(
mut netif: libc::c_uint,
mut addr: *const ipv6_addr_t,
) -> uint32_t {
return dhcpv6_client_prefix_valid_until(
netif,
addr,
IPV6_ADDR_BIT_LEN as libc::c_uint,
);
}
#[inline]
pub unsafe fn eui64_set_local(mut addr: *mut eui64_t) {
(*addr)
.uint8[0 as libc::c_int
as usize] = ((*addr).uint8[0 as libc::c_int as usize] as libc::c_int
| EUI64_LOCAL_FLAG) as uint8_t;
}
pub const EUI64_LOCAL_FLAG: libc::c_int = 0x2 as libc::c_int;
#[inline]
pub unsafe fn eui64_clear_group(mut addr: *mut eui64_t) {
(*addr)
.uint8[0 as libc::c_int
as usize] = ((*addr).uint8[0 as libc::c_int as usize] as libc::c_int
& !EUI64_GROUP_FLAG) as uint8_t;
}
pub const EUI64_GROUP_FLAG: libc::c_int = 0x1 as libc::c_int;
#[inline]
pub unsafe fn ieee802154_get_seq(mut mhr: *const uint8_t) -> uint8_t {
return *mhr.offset(2 as libc::c_int as isize);
}
#[inline]
pub unsafe fn ieee802154_get_iid(
mut eui64: *mut eui64_t,
mut addr: *const uint8_t,
mut addr_len: size_t,
) -> *mut eui64_t {
let mut i: libc::c_int = 0 as libc::c_int;
(*eui64).uint8[1 as libc::c_int as usize] = 0 as libc::c_int as uint8_t;
(*eui64)
.uint8[0 as libc::c_int as usize] = (*eui64).uint8[1 as libc::c_int as usize];
let mut current_block_17: u64;
match addr_len {
8 => {
let fresh36 = i;
i = i + 1;
(*eui64)
.uint8[0 as libc::c_int
as usize] = (*addr.offset(fresh36 as isize) as libc::c_int
^ 0x2 as libc::c_int) as uint8_t;
let fresh37 = i;
i = i + 1;
(*eui64).uint8[1 as libc::c_int as usize] = *addr.offset(fresh37 as isize);
let fresh38 = i;
i = i + 1;
(*eui64).uint8[2 as libc::c_int as usize] = *addr.offset(fresh38 as isize);
let fresh39 = i;
i = i + 1;
(*eui64).uint8[3 as libc::c_int as usize] = *addr.offset(fresh39 as isize);
let fresh40 = i;
i = i + 1;
(*eui64).uint8[4 as libc::c_int as usize] = *addr.offset(fresh40 as isize);
let fresh41 = i;
i = i + 1;
(*eui64).uint8[5 as libc::c_int as usize] = *addr.offset(fresh41 as isize);
let fresh42 = i;
i = i + 1;
(*eui64).uint8[6 as libc::c_int as usize] = *addr.offset(fresh42 as isize);
let fresh43 = i;
i = i + 1;
(*eui64).uint8[7 as libc::c_int as usize] = *addr.offset(fresh43 as isize);
current_block_17 = 3512920355445576850;
}
4 => {
let fresh44 = i;
i = i + 1;
(*eui64)
.uint8[0 as libc::c_int
as usize] = (*addr.offset(fresh44 as isize) as libc::c_int
^ 0x2 as libc::c_int) as uint8_t;
let fresh45 = i;
i = i + 1;
(*eui64).uint8[1 as libc::c_int as usize] = *addr.offset(fresh45 as isize);
current_block_17 = 13395312208073836257;
}
2 => {
current_block_17 = 13395312208073836257;
}
_ => return NULL_1 as *mut eui64_t,
}
match current_block_17 {
13395312208073836257 => {
(*eui64).uint8[2 as libc::c_int as usize] = 0 as libc::c_int as uint8_t;
(*eui64).uint8[3 as libc::c_int as usize] = 0xff as libc::c_int as uint8_t;
(*eui64).uint8[4 as libc::c_int as usize] = 0xfe as libc::c_int as uint8_t;
(*eui64).uint8[5 as libc::c_int as usize] = 0 as libc::c_int as uint8_t;
let fresh46 = i;
i = i + 1;
(*eui64).uint8[6 as libc::c_int as usize] = *addr.offset(fresh46 as isize);
let fresh47 = i;
i = i + 1;
(*eui64).uint8[7 as libc::c_int as usize] = *addr.offset(fresh47 as isize);
}
_ => {}
}
return eui64;
}
#[inline]
pub unsafe fn ieee802154_rssi_to_dbm(mut rssi: uint8_t) -> int16_t {
return (rssi as libc::c_int + IEEE802154_RADIO_RSSI_OFFSET) as int16_t;
}
pub const IEEE802154_RADIO_RSSI_OFFSET: libc::c_int = -(174 as libc::c_int);
#[inline]
pub unsafe fn ieee802154_dbm_to_rssi(mut dbm: int16_t) -> uint8_t {
let min: libc::c_int = IEEE802154_RADIO_RSSI_OFFSET;
let max: libc::c_int = min + (UINT8_MAX - 1 as libc::c_int);
let mut val: libc::c_int = if dbm as libc::c_int <= min {
min
} else if dbm as libc::c_int >= max {
max
} else {
dbm as libc::c_int
};
return (val - IEEE802154_RADIO_RSSI_OFFSET) as uint8_t;
}
#[inline]
pub unsafe fn evtimer_now_msec() -> uint32_t {
return ztimer_now(ZTIMER_MSEC);
}
#[inline]
pub unsafe fn evtimer_add_msg(
mut evtimer: *mut evtimer_msg_t,
mut event: *mut evtimer_msg_event_t,
mut target_pid: kernel_pid_t,
) {
(*event).msg.sender_pid = target_pid;
evtimer_add(evtimer, &mut (*event).event);
}
#[inline]
unsafe extern "C" fn _evtimer_msg_handler(mut event: *mut evtimer_event_t) {
let mut mevent: *mut evtimer_msg_event_t = event as *mut evtimer_msg_event_t;
msg_send_int(&mut (*mevent).msg, (*mevent).msg.sender_pid);
}
#[inline]
pub unsafe fn evtimer_init_msg(mut evtimer: *mut evtimer_t) {
evtimer_init(
evtimer,
Some(_evtimer_msg_handler as unsafe extern "C" fn(*mut evtimer_event_t) -> ()),
);
}
#[inline]
pub unsafe fn l2util_addr_equal(
mut addr_a: *const uint8_t,
mut addr_a_len: uint8_t,
mut addr_b: *const uint8_t,
mut addr_b_len: uint8_t,
) -> bool {
if addr_a_len as libc::c_int != addr_b_len as libc::c_int {
return false_0 != 0;
}
return memcmp(
addr_a as *const libc::c_void,
addr_b as *const libc::c_void,
addr_a_len as libc::c_uint,
) == 0 as libc::c_int;
}
#[inline]
pub unsafe fn netdev_register(
mut dev: *mut netdev,
mut type_0: netdev_type_t,
mut index: uint8_t,
) {}
#[inline]
pub unsafe fn netdev_get_notsup(
mut dev: *mut netdev_t,
mut opt: netopt_t,
mut value: *mut libc::c_void,
mut max_len: size_t,
) -> libc::c_int {
return -ENOTSUP;
}
pub const ENOTSUP: libc::c_int = 134 as libc::c_int;
#[inline]
pub unsafe fn netdev_set_notsup(
mut dev: *mut netdev_t,
mut opt: netopt_t,
mut value: *const libc::c_void,
mut value_len: size_t,
) -> libc::c_int {
return -ENOTSUP;
}
#[inline]
pub unsafe fn netdev_trigger_event_isr(mut netdev: *mut netdev_t) {
if ((*netdev).event_callback).is_some() {
((*netdev).event_callback)
.expect("non-null function pointer")(netdev, NETDEV_EVENT_ISR);
}
}
#[inline]
pub unsafe fn ipv6_ext_frag_get_offset(
mut frag: *const ipv6_ext_frag_t,
) -> libc::c_uint {
return (byteorder_ntohs((*frag).offset_flags) as libc::c_int
& IPV6_EXT_FRAG_OFFSET_MASK) as libc::c_uint;
}
pub const IPV6_EXT_FRAG_OFFSET_MASK: libc::c_int = 0xfff8 as libc::c_int;
#[inline]
pub unsafe fn ipv6_ext_frag_more(mut frag: *const ipv6_ext_frag_t) -> bool {
return byteorder_ntohs((*frag).offset_flags) as libc::c_int & IPV6_EXT_FRAG_M != 0;
}
pub const IPV6_EXT_FRAG_M: libc::c_int = 0x1 as libc::c_int;
#[inline]
pub unsafe fn ipv6_ext_frag_set_offset(
mut frag: *mut ipv6_ext_frag_t,
mut offset: libc::c_uint,
) {
(*frag)
.offset_flags = byteorder_htons(
(offset & IPV6_EXT_FRAG_OFFSET_MASK as libc::c_uint) as uint16_t,
);
}
#[inline]
pub unsafe fn ipv6_ext_frag_set_more(mut frag: *mut ipv6_ext_frag_t) {
(*frag)
.offset_flags
.u8_0[1 as libc::c_int
as usize] = ((*frag).offset_flags.u8_0[1 as libc::c_int as usize] as libc::c_int
| IPV6_EXT_FRAG_M) as uint8_t;
}
#[inline]
pub unsafe fn ipv6_ext_get_next(mut ext: *mut ipv6_ext_t) -> *mut ipv6_ext_t {
return (ext as *mut uint8_t)
.offset(((*ext).len as libc::c_uint).wrapping_mul(IPV6_EXT_LEN_UNIT) as isize)
.offset(IPV6_EXT_LEN_UNIT as isize) as *mut ipv6_ext_t;
}
pub const IPV6_EXT_LEN_UNIT: libc::c_uint = 8 as libc::c_uint;
#[inline]
pub unsafe fn inet_csum(
mut sum: uint16_t,
mut buf: *const uint8_t,
mut len: uint16_t,
) -> uint16_t {
return inet_csum_slice(sum, buf, len, 0 as libc::c_int as size_t);
}
#[inline]
pub unsafe fn ipv6_hdr_set_version(mut hdr: *mut ipv6_hdr_t) {
(*hdr)
.v_tc_fl
.u8_0[0 as libc::c_int
as usize] = ((*hdr).v_tc_fl.u8_0[0 as libc::c_int as usize] as libc::c_int
& 0xf as libc::c_int) as uint8_t;
(*hdr)
.v_tc_fl
.u8_0[0 as libc::c_int
as usize] = ((*hdr).v_tc_fl.u8_0[0 as libc::c_int as usize] as libc::c_int
| 0x60 as libc::c_int) as uint8_t;
}
#[inline]
pub unsafe fn ipv6_hdr_get_version(mut hdr: *const ipv6_hdr_t) -> uint8_t {
return ((*hdr).v_tc_fl.u8_0[0 as libc::c_int as usize] as libc::c_int
>> 4 as libc::c_int) as uint8_t;
}
#[inline]
pub unsafe fn ipv6_hdr_is(mut hdr: *const ipv6_hdr_t) -> bool {
return (*hdr).v_tc_fl.u8_0[0 as libc::c_int as usize] as libc::c_int
& 0xf0 as libc::c_int == 0x60 as libc::c_int;
}
#[inline]
pub unsafe fn ipv6_hdr_set_tc(mut hdr: *mut ipv6_hdr_t, mut tc: uint8_t) {
(*hdr)
.v_tc_fl
.u8_0[0 as libc::c_int
as usize] = ((*hdr).v_tc_fl.u8_0[0 as libc::c_int as usize] as libc::c_int
& 0xf0 as libc::c_int) as uint8_t;
(*hdr)
.v_tc_fl
.u8_0[0 as libc::c_int
as usize] = ((*hdr).v_tc_fl.u8_0[0 as libc::c_int as usize] as libc::c_int
| 0xf as libc::c_int & tc as libc::c_int >> 4 as libc::c_int) as uint8_t;
(*hdr)
.v_tc_fl
.u8_0[1 as libc::c_int
as usize] = ((*hdr).v_tc_fl.u8_0[1 as libc::c_int as usize] as libc::c_int
& 0xf as libc::c_int) as uint8_t;
(*hdr)
.v_tc_fl
.u8_0[1 as libc::c_int
as usize] = ((*hdr).v_tc_fl.u8_0[1 as libc::c_int as usize] as libc::c_int
| 0xf0 as libc::c_int & (tc as libc::c_int) << 4 as libc::c_int) as uint8_t;
}
#[inline]
pub unsafe fn ipv6_hdr_set_tc_ecn(mut hdr: *mut ipv6_hdr_t, mut ecn: uint8_t) {
(*hdr)
.v_tc_fl
.u8_0[0 as libc::c_int
as usize] = ((*hdr).v_tc_fl.u8_0[0 as libc::c_int as usize] as libc::c_int
& 0xf3 as libc::c_int) as uint8_t;
(*hdr)
.v_tc_fl
.u8_0[0 as libc::c_int
as usize] = ((*hdr).v_tc_fl.u8_0[0 as libc::c_int as usize] as libc::c_int
| 0xc as libc::c_int & (ecn as libc::c_int) << 2 as libc::c_int) as uint8_t;
}
#[inline]
pub unsafe fn ipv6_hdr_set_tc_dscp(mut hdr: *mut ipv6_hdr_t, mut dscp: uint8_t) {
(*hdr)
.v_tc_fl
.u8_0[0 as libc::c_int
as usize] = ((*hdr).v_tc_fl.u8_0[0 as libc::c_int as usize] as libc::c_int
& 0xfc as libc::c_int) as uint8_t;
(*hdr)
.v_tc_fl
.u8_0[0 as libc::c_int
as usize] = ((*hdr).v_tc_fl.u8_0[0 as libc::c_int as usize] as libc::c_int
| 0x3 as libc::c_int & dscp as libc::c_int >> 4 as libc::c_int) as uint8_t;
(*hdr)
.v_tc_fl
.u8_0[1 as libc::c_int
as usize] = ((*hdr).v_tc_fl.u8_0[1 as libc::c_int as usize] as libc::c_int
& 0xf as libc::c_int) as uint8_t;
(*hdr)
.v_tc_fl
.u8_0[1 as libc::c_int
as usize] = ((*hdr).v_tc_fl.u8_0[1 as libc::c_int as usize] as libc::c_int
| 0xf0 as libc::c_int & (dscp as libc::c_int) << 4 as libc::c_int) as uint8_t;
}
#[inline]
pub unsafe fn ipv6_hdr_get_tc(mut hdr: *const ipv6_hdr_t) -> uint8_t {
return (((*hdr).v_tc_fl.u8_0[0 as libc::c_int as usize] as libc::c_int
& 0xf as libc::c_int) << 4 as libc::c_int
| ((*hdr).v_tc_fl.u8_0[1 as libc::c_int as usize] as libc::c_int
& 0xf0 as libc::c_int) >> 4 as libc::c_int) as uint8_t;
}
#[inline]
pub unsafe fn ipv6_hdr_get_tc_ecn(mut hdr: *const ipv6_hdr_t) -> uint8_t {
return (((*hdr).v_tc_fl.u8_0[0 as libc::c_int as usize] as libc::c_int
& 0xc as libc::c_int) >> 2 as libc::c_int) as uint8_t;
}
#[inline]
pub unsafe fn ipv6_hdr_get_tc_dscp(mut hdr: *const ipv6_hdr_t) -> uint8_t {
return (((*hdr).v_tc_fl.u8_0[0 as libc::c_int as usize] as libc::c_int
& 0x3 as libc::c_int) << 4 as libc::c_int
| ((*hdr).v_tc_fl.u8_0[1 as libc::c_int as usize] as libc::c_int
& 0xf0 as libc::c_int) >> 4 as libc::c_int) as uint8_t;
}
#[inline]
pub unsafe fn ipv6_hdr_set_fl(mut hdr: *mut ipv6_hdr_t, mut fl: uint32_t) {
(*hdr)
.v_tc_fl
.u8_0[1 as libc::c_int
as usize] = ((*hdr).v_tc_fl.u8_0[1 as libc::c_int as usize] as libc::c_int
& 0xf0 as libc::c_int) as uint8_t;
(*hdr)
.v_tc_fl
.u8_0[1 as libc::c_int
as usize] = ((*hdr).v_tc_fl.u8_0[1 as libc::c_int as usize] as libc::c_int
| 0xf as libc::c_int
& (byteorder_htonl(fl)).u8_0[1 as libc::c_int as usize] as libc::c_int)
as uint8_t;
(*hdr)
.v_tc_fl
.u16_0[1 as libc::c_int
as usize] = (byteorder_htonl(fl)).u16_0[1 as libc::c_int as usize];
}
#[inline]
pub unsafe fn ipv6_hdr_get_fl(mut hdr: *const ipv6_hdr_t) -> uint32_t {
return byteorder_ntohl((*hdr).v_tc_fl) & 0xfffff as libc::c_int as libc::c_uint;
}
#[inline]
pub unsafe fn ipv6_hdr_inet_csum(
mut sum: uint16_t,
mut hdr: *mut ipv6_hdr_t,
mut prot_num: uint8_t,
mut len: uint16_t,
) -> uint16_t {
if (sum as uint32_t)
.wrapping_add(len as libc::c_uint)
.wrapping_add(prot_num as libc::c_uint) > 0xffff as libc::c_int as libc::c_uint
{
sum = sum.wrapping_add(1);
sum;
}
return inet_csum(
(sum as libc::c_int + len as libc::c_int + prot_num as libc::c_int) as uint16_t,
((*hdr).src.u8_0).as_mut_ptr(),
(2 as libc::c_int as libc::c_uint)
.wrapping_mul(::core::mem::size_of::<ipv6_addr_t>() as libc::c_ulong)
as uint16_t,
);
}
#[inline]
pub unsafe fn netif_get_by_name(mut name: *const libc::c_char) -> *mut netif_t {
return netif_get_by_name_buffer(name, strlen(name));
}
#[inline]
pub unsafe fn netif_get_ipv6(
mut netif: *mut netif_t,
mut dest: *mut ipv6_addr_t,
mut numof: size_t,
) -> ssize_t {
let mut res: libc::c_int = netif_get_opt(
netif,
NETOPT_IPV6_ADDR,
0 as libc::c_int as uint16_t,
dest as *mut libc::c_void,
(::core::mem::size_of::<ipv6_addr_t>() as libc::c_ulong).wrapping_mul(numof),
);
if res < 0 as libc::c_int {
return -(1 as libc::c_int);
}
return (res as libc::c_uint)
.wrapping_div(::core::mem::size_of::<ipv6_addr_t>() as libc::c_ulong) as ssize_t;
}
#[inline]
pub unsafe fn gnrc_netif_netdev_legacy_api(mut netif: *mut gnrc_netif_t) -> bool {
if 0 as libc::c_int == 0 && 0 as libc::c_int == 0 {
return true_0 != 0;
}
if 0 as libc::c_int == 0 {
return true_0 != 0;
}
if 0 as libc::c_int == 0 {
return false_0 != 0;
}
return ((*(*(*netif).dev).driver).confirm_send).is_none();
}
#[inline]
pub unsafe fn gnrc_netif_netdev_new_api(mut netif: *mut gnrc_netif_t) -> bool {
return !gnrc_netif_netdev_legacy_api(netif);
}
#[inline]
pub unsafe fn gnrc_netif_highlander() -> bool {
return 0 as libc::c_int != 0;
}
#[inline]
pub unsafe fn gnrc_netif_ipv6_addrs_get(
mut netif: *const gnrc_netif_t,
mut addrs: *mut ipv6_addr_t,
mut max_len: size_t,
) -> libc::c_int {
if (netif != 0 as *mut libc::c_void as *const gnrc_netif_t) as libc::c_int
as uintptr_t as libc::c_long != 0
{} else {
_assert_panic();
};
if (addrs != 0 as *mut libc::c_void as *mut ipv6_addr_t) as libc::c_int as uintptr_t
as libc::c_long != 0
{} else {
_assert_panic();
};
if (max_len >= ::core::mem::size_of::<ipv6_addr_t>() as libc::c_ulong) as libc::c_int
as uintptr_t as libc::c_long != 0
{} else {
_assert_panic();
};
return gnrc_netapi_get(
(*netif).pid,
NETOPT_IPV6_ADDR,
0 as libc::c_int as uint16_t,
addrs as *mut libc::c_void,
max_len,
);
}
#[inline]
pub unsafe fn gnrc_netif_ipv6_addr_add(
mut netif: *const gnrc_netif_t,
mut addr: *const ipv6_addr_t,
mut pfx_len: libc::c_uint,
mut flags: uint8_t,
) -> libc::c_int {
if (netif != 0 as *mut libc::c_void as *const gnrc_netif_t) as libc::c_int
as uintptr_t as libc::c_long != 0
{} else {
_assert_panic();
};
if (addr != 0 as *mut libc::c_void as *const ipv6_addr_t) as libc::c_int as uintptr_t
as libc::c_long != 0
{} else {
_assert_panic();
};
if (pfx_len > 0 as libc::c_int as libc::c_uint
&& pfx_len <= 128 as libc::c_int as libc::c_uint) as libc::c_int as uintptr_t
as libc::c_long != 0
{} else {
_assert_panic();
};
return gnrc_netapi_set(
(*netif).pid,
NETOPT_IPV6_ADDR,
(pfx_len << 8 as libc::c_uint | flags as libc::c_uint) as uint16_t,
addr as *const libc::c_void,
::core::mem::size_of::<ipv6_addr_t>() as libc::c_ulong,
);
}
#[inline]
pub unsafe fn gnrc_netif_ipv6_addr_remove(
mut netif: *const gnrc_netif_t,
mut addr: *const ipv6_addr_t,
) -> libc::c_int {
if (netif != 0 as *mut libc::c_void as *const gnrc_netif_t) as libc::c_int
as uintptr_t as libc::c_long != 0
{} else {
_assert_panic();
};
if (addr != 0 as *mut libc::c_void as *const ipv6_addr_t) as libc::c_int as uintptr_t
as libc::c_long != 0
{} else {
_assert_panic();
};
return gnrc_netapi_set(
(*netif).pid,
NETOPT_IPV6_ADDR_REMOVE,
0 as libc::c_int as uint16_t,
addr as *const libc::c_void,
::core::mem::size_of::<ipv6_addr_t>() as libc::c_ulong,
);
}
#[inline]
pub unsafe fn gnrc_netif_ipv6_groups_get(
mut netif: *const gnrc_netif_t,
mut groups: *mut ipv6_addr_t,
mut max_len: size_t,
) -> libc::c_int {
if (netif != 0 as *mut libc::c_void as *const gnrc_netif_t) as libc::c_int
as uintptr_t as libc::c_long != 0
{} else {
_assert_panic();
};
if (groups != 0 as *mut libc::c_void as *mut ipv6_addr_t) as libc::c_int as uintptr_t
as libc::c_long != 0
{} else {
_assert_panic();
};
if (max_len >= ::core::mem::size_of::<ipv6_addr_t>() as libc::c_ulong) as libc::c_int
as uintptr_t as libc::c_long != 0
{} else {
_assert_panic();
};
return gnrc_netapi_get(
(*netif).pid,
NETOPT_IPV6_GROUP,
0 as libc::c_int as uint16_t,
groups as *mut libc::c_void,
max_len,
);
}
#[inline]
pub unsafe fn gnrc_netif_ipv6_group_join(
mut netif: *const gnrc_netif_t,
mut group: *const ipv6_addr_t,
) -> libc::c_int {
if (netif != 0 as *mut libc::c_void as *const gnrc_netif_t) as libc::c_int
as uintptr_t as libc::c_long != 0
{} else {
_assert_panic();
};
if (group != 0 as *mut libc::c_void as *const ipv6_addr_t) as libc::c_int
as uintptr_t as libc::c_long != 0
{} else {
_assert_panic();
};
return gnrc_netapi_set(
(*netif).pid,
NETOPT_IPV6_GROUP,
0 as libc::c_int as uint16_t,
group as *const libc::c_void,
::core::mem::size_of::<ipv6_addr_t>() as libc::c_ulong,
);
}
#[inline]
pub unsafe fn gnrc_netif_ipv6_group_leave(
mut netif: *const gnrc_netif_t,
mut group: *const ipv6_addr_t,
) -> libc::c_int {
if (netif != 0 as *mut libc::c_void as *const gnrc_netif_t) as libc::c_int
as uintptr_t as libc::c_long != 0
{} else {
_assert_panic();
};
if (group != 0 as *mut libc::c_void as *const ipv6_addr_t) as libc::c_int
as uintptr_t as libc::c_long != 0
{} else {
_assert_panic();
};
return gnrc_netapi_set(
(*netif).pid,
NETOPT_IPV6_GROUP_LEAVE,
0 as libc::c_int as uint16_t,
group as *const libc::c_void,
::core::mem::size_of::<ipv6_addr_t>() as libc::c_ulong,
);
}
#[inline]
pub unsafe fn gnrc_netif_addr_to_str(
mut addr: *const uint8_t,
mut addr_len: size_t,
mut out: *mut libc::c_char,
) -> *mut libc::c_char {
return l2util_addr_to_str(addr, addr_len, out);
}
#[inline]
pub unsafe fn gnrc_netif_addr_from_str(
mut str: *const libc::c_char,
mut out: *mut uint8_t,
) -> size_t {
return l2util_addr_from_str(str, out);
}
#[inline]
pub unsafe fn gnrc_netif_send(
mut netif: *mut gnrc_netif_t,
mut pkt: *mut gnrc_pktsnip_t,
) -> libc::c_int {
return gnrc_netapi_send((*netif).pid, pkt);
}
#[inline]
pub unsafe fn gnrc_netif_ipv6_addr_get_state(
mut netif: *const gnrc_netif_t,
mut idx: libc::c_int,
) -> uint8_t {
return ((*netif).ipv6.addrs_flags[idx as usize] as libc::c_uint
& GNRC_NETIF_IPV6_ADDRS_FLAGS_STATE_MASK) as uint8_t;
}
pub const GNRC_NETIF_IPV6_ADDRS_FLAGS_STATE_MASK: libc::c_uint = 0x1f as libc::c_uint;
#[inline]
pub unsafe fn gnrc_netif_ipv6_addr_dad_trans(
mut netif: *const gnrc_netif_t,
mut idx: libc::c_int,
) -> uint8_t {
return ((*netif).ipv6.addrs_flags[idx as usize] as libc::c_uint
& GNRC_NETIF_IPV6_ADDRS_FLAGS_STATE_TENTATIVE) as uint8_t;
}
pub const GNRC_NETIF_IPV6_ADDRS_FLAGS_STATE_TENTATIVE: libc::c_uint = 0x7
as libc::c_uint;
#[inline]
pub unsafe fn gnrc_netif_ipv6_bus_post(
mut netif: *mut gnrc_netif_t,
mut type_0: libc::c_int,
mut ctx: *const libc::c_void,
) {}
#[inline]
pub unsafe fn gnrc_netif_is_rtr(mut netif: *const gnrc_netif_t) -> bool {
return false_0 != 0;
}
pub const GNRC_NETIF_FLAGS_IPV6_FORWARDING: libc::c_uint = 0x2 as libc::c_uint;
#[inline]
pub unsafe fn gnrc_netif_is_rtr_adv(mut netif: *const gnrc_netif_t) -> bool {
return false_0 != 0;
}
pub const GNRC_NETIF_FLAGS_IPV6_RTR_ADV: libc::c_uint = 0x4 as libc::c_uint;
#[inline]
pub unsafe fn gnrc_netif_is_6lo(mut netif: *const gnrc_netif_t) -> bool {
if !gnrc_netif_highlander() && 0 as libc::c_int != 0 || 0 as libc::c_int != 0 {
return gnrc_netif_dev_is_6lo(netif)
} else if gnrc_netif_highlander() as libc::c_int != 0 && 0 as libc::c_int != 0 {
return true_0 != 0
} else {
return false_0 != 0
};
}
#[inline]
pub unsafe fn gnrc_netif_is_6ln(mut netif: *const gnrc_netif_t) -> bool {
return false_0 != 0;
}
pub const GNRC_NETIF_FLAGS_6LN: libc::c_uint = 0x1000 as libc::c_uint;
#[inline]
pub unsafe fn gnrc_netif_is_6lr(mut netif: *const gnrc_netif_t) -> bool {
if 0 as libc::c_int != 0
&& (0 as libc::c_int != 0 || !gnrc_netif_highlander() || 0 as libc::c_int == 0)
{
return gnrc_netif_is_rtr(netif) as libc::c_int != 0
&& gnrc_netif_is_6ln(netif) as libc::c_int != 0
} else {
return false_0 != 0
};
}
#[inline]
pub unsafe fn gnrc_netif_is_6lbr(mut netif: *const gnrc_netif_t) -> bool {
return false_0 != 0;
}
pub const GNRC_NETIF_FLAGS_6LO_ABR: libc::c_uint = 0x200 as libc::c_uint;
#[inline]
pub unsafe fn gnrc_netif_get_eui64(
mut netif: *mut gnrc_netif_t,
mut eui64: *mut eui64_t,
) -> libc::c_int {
if (*netif).flags & GNRC_NETIF_FLAGS_HAS_L2ADDR != 0 {
return gnrc_netif_eui64_from_addr(
netif,
((*netif).l2addr).as_mut_ptr(),
(*netif).l2addr_len as size_t,
eui64,
);
}
return -ENOTSUP;
}
pub const GNRC_NETIF_FLAGS_HAS_L2ADDR: libc::c_uint = 0x1 as libc::c_uint;
#[inline]
pub unsafe fn gnrc_netif_ipv6_iid_to_addr(
mut netif: *const gnrc_netif_t,
mut iid: *const eui64_t,
mut addr: *mut uint8_t,
) -> libc::c_int {
if ((*netif).flags & 0x1 as libc::c_uint) as libc::c_long != 0 {} else {
_assert_panic();
};
return l2util_ipv6_iid_to_addr((*netif).device_type as libc::c_int, iid, addr);
}
#[inline]
pub unsafe fn gnrc_netif_ipv6_get_iid(
mut netif: *mut gnrc_netif_t,
mut iid: *mut eui64_t,
) -> libc::c_int {
if (*netif).flags & GNRC_NETIF_FLAGS_HAS_L2ADDR != 0 {
return gnrc_netif_ipv6_iid_from_addr(
netif,
((*netif).l2addr).as_mut_ptr(),
(*netif).l2addr_len as size_t,
iid,
);
}
return -ENOTSUP;
}
#[inline]
pub unsafe fn gnrc_netif_ndp_addr_len_from_l2ao(
mut netif: *mut gnrc_netif_t,
mut opt: *const ndp_opt_t,
) -> libc::c_int {
if ((*netif).flags & 0x1 as libc::c_uint) as libc::c_long != 0 {} else {
_assert_panic();
};
return l2util_ndp_addr_len_from_l2ao((*netif).device_type as libc::c_int, opt);
}
#[inline]
pub unsafe fn gnrc_netif_ipv6_group_to_l2_group(
mut netif: *mut gnrc_netif_t,
mut ipv6_group: *const ipv6_addr_t,
mut l2_group: *mut uint8_t,
) -> libc::c_int {
return l2util_ipv6_group_to_l2_group(
(*netif).device_type as libc::c_int,
ipv6_group,
l2_group,
);
}
#[inline]
pub unsafe fn gnrc_pktbuf_release(mut pkt: *mut gnrc_pktsnip_t) {
gnrc_pktbuf_release_error(pkt, GNRC_NETERR_SUCCESS as uint32_t);
}
pub const GNRC_NETERR_SUCCESS: libc::c_int = 0 as libc::c_int;
#[inline]
pub unsafe fn gnrc_netif_hdr_init(
mut hdr: *mut gnrc_netif_hdr_t,
mut src_l2addr_len: uint8_t,
mut dst_l2addr_len: uint8_t,
) {
(*hdr).src_l2addr_len = src_l2addr_len;
(*hdr).dst_l2addr_len = dst_l2addr_len;
(*hdr).if_pid = KERNEL_PID_UNDEF as kernel_pid_t;
(*hdr).rssi = GNRC_NETIF_HDR_NO_RSSI as int16_t;
(*hdr).lqi = GNRC_NETIF_HDR_NO_LQI as uint8_t;
(*hdr).flags = 0 as libc::c_int as uint8_t;
}
pub const GNRC_NETIF_HDR_NO_LQI: libc::c_int = 0 as libc::c_int;
pub const GNRC_NETIF_HDR_NO_RSSI: libc::c_int = -__INT16_MAX__ - 1 as libc::c_int;
#[inline]
pub unsafe fn gnrc_netif_hdr_sizeof(mut hdr: *const gnrc_netif_hdr_t) -> size_t {
return (::core::mem::size_of::<gnrc_netif_hdr_t>() as libc::c_ulong)
.wrapping_add((*hdr).src_l2addr_len as libc::c_uint)
.wrapping_add((*hdr).dst_l2addr_len as libc::c_uint);
}
#[inline]
pub unsafe fn gnrc_netif_hdr_get_src_addr(
mut hdr: *const gnrc_netif_hdr_t,
) -> *mut uint8_t {
return hdr.offset(1 as libc::c_int as isize) as *mut uint8_t;
}
#[inline]
pub unsafe fn gnrc_netif_hdr_set_src_addr(
mut hdr: *mut gnrc_netif_hdr_t,
mut addr: *const uint8_t,
mut addr_len: uint8_t,
) {
if addr_len as libc::c_int != (*hdr).src_l2addr_len as libc::c_int {
return;
}
memcpy(
hdr.offset(1 as libc::c_int as isize) as *mut uint8_t as *mut libc::c_void,
addr as *const libc::c_void,
addr_len as libc::c_uint,
);
}
#[inline]
pub unsafe fn gnrc_netif_hdr_get_dst_addr(
mut hdr: *const gnrc_netif_hdr_t,
) -> *mut uint8_t {
return (hdr.offset(1 as libc::c_int as isize) as *mut uint8_t)
.offset((*hdr).src_l2addr_len as libc::c_int as isize);
}
#[inline]
pub unsafe fn gnrc_netif_hdr_set_dst_addr(
mut hdr: *mut gnrc_netif_hdr_t,
mut addr: *const uint8_t,
mut addr_len: uint8_t,
) {
if addr_len as libc::c_int != (*hdr).dst_l2addr_len as libc::c_int {
return;
}
memcpy(
(hdr.offset(1 as libc::c_int as isize) as *mut uint8_t)
.offset((*hdr).src_l2addr_len as libc::c_int as isize) as *mut libc::c_void,
addr as *const libc::c_void,
addr_len as libc::c_uint,
);
}
#[inline]
pub unsafe fn gnrc_netif_hdr_set_timestamp(
mut hdr: *mut gnrc_netif_hdr_t,
mut timestamp: uint64_t,
) {}
#[inline]
pub unsafe fn gnrc_netif_hdr_get_timestamp(
mut hdr: *const gnrc_netif_hdr_t,
mut dest: *mut uint64_t,
) -> libc::c_int {
return -(1 as libc::c_int);
}
#[inline]
pub unsafe fn gnrc_netif_hdr_ipv6_iid_from_src(
mut netif: *const gnrc_netif_t,
mut hdr: *const gnrc_netif_hdr_t,
mut iid: *mut eui64_t,
) -> libc::c_int {
return gnrc_netif_ipv6_iid_from_addr(
netif,
gnrc_netif_hdr_get_src_addr(hdr),
(*hdr).src_l2addr_len as size_t,
iid,
);
}
#[inline]
pub unsafe fn gnrc_netif_hdr_ipv6_iid_from_dst(
mut netif: *const gnrc_netif_t,
mut hdr: *const gnrc_netif_hdr_t,
mut iid: *mut eui64_t,
) -> libc::c_int {
return gnrc_netif_ipv6_iid_from_addr(
netif,
gnrc_netif_hdr_get_dst_addr(hdr),
(*hdr).dst_l2addr_len as size_t,
iid,
);
}
#[inline]
pub unsafe fn gnrc_netif_hdr_get_netif(
mut hdr: *const gnrc_netif_hdr_t,
) -> *mut gnrc_netif_t {
if (hdr != 0 as *mut libc::c_void as *const gnrc_netif_hdr_t) as libc::c_int
as uintptr_t as libc::c_long != 0
{} else {
_assert_panic();
};
return gnrc_netif_get_by_pid((*hdr).if_pid);
}
#[inline]
pub unsafe fn gnrc_netif_hdr_set_netif(
mut hdr: *mut gnrc_netif_hdr_t,
mut netif: *const gnrc_netif_t,
) {
(*hdr)
.if_pid = (if !netif.is_null() {
(*netif).pid as libc::c_int
} else {
KERNEL_PID_UNDEF
}) as kernel_pid_t;
}
#[inline]
pub unsafe fn ringbuffer_init(
mut rb: *mut ringbuffer_t,
mut buffer: *mut libc::c_char,
mut bufsize: libc::c_uint,
) {
(*rb).buf = buffer;
(*rb).size = bufsize;
(*rb).start = 0 as libc::c_int as libc::c_uint;
(*rb).avail = 0 as libc::c_int as libc::c_uint;
}
#[inline]
pub unsafe fn ringbuffer_empty(mut rb: *const ringbuffer_t) -> libc::c_int {
return ((*rb).avail == 0 as libc::c_int as libc::c_uint) as libc::c_int;
}
#[inline]
pub unsafe fn ringbuffer_full(mut rb: *const ringbuffer_t) -> libc::c_int {
return ((*rb).avail == (*rb).size) as libc::c_int;
}
#[inline]
pub unsafe fn ringbuffer_get_free(mut rb: *const ringbuffer_t) -> libc::c_uint {
return ((*rb).size).wrapping_sub((*rb).avail);
}
#[inline]
pub unsafe fn evtimer_add_mbox(
mut evtimer: *mut evtimer_t,
mut event: *mut evtimer_mbox_event_t,
mut mbox: *mut mbox_t,
) {
if evtimer as uintptr_t as libc::c_long != 0 {} else {
_assert_panic();
};
if event as uintptr_t as libc::c_long != 0 {} else {
_assert_panic();
};
if mbox as uintptr_t as libc::c_long != 0 {} else {
_assert_panic();
};
(*event).mbox = mbox;
evtimer_add(evtimer, &mut (*event).event);
}
#[inline]
unsafe extern "C" fn _evtimer_mbox_handler(mut event: *mut evtimer_event_t) {
if event as uintptr_t as libc::c_long != 0 {} else {
_assert_panic();
};
let mut mbevent: *mut evtimer_mbox_event_t = event as *mut evtimer_mbox_event_t;
mbox_try_put((*mbevent).mbox, &mut (*mbevent).msg);
}
#[inline]
pub unsafe fn evtimer_init_mbox(mut evtimer: *mut evtimer_t) {
if evtimer as uintptr_t as libc::c_long != 0 {} else {
_assert_panic();
};
evtimer_init(
evtimer,
Some(_evtimer_mbox_handler as unsafe extern "C" fn(*mut evtimer_event_t) -> ()),
);
}
#[inline]
pub unsafe fn timex_normalize(mut time: *mut timex_t) {
(*time)
.seconds = ((*time).seconds as libc::c_ulong)
.wrapping_add(((*time).microseconds as libc::c_ulong).wrapping_div(US_PER_SEC))
as uint32_t as uint32_t;
(*time)
.microseconds = ((*time).microseconds as libc::c_ulong).wrapping_rem(US_PER_SEC)
as uint32_t as uint32_t;
}
pub const US_PER_SEC: libc::c_ulong = 1000000 as libc::c_ulong;
#[inline]
pub unsafe fn timex_isnormalized(mut time: *const timex_t) -> libc::c_int {
return (((*time).microseconds as libc::c_ulong) < US_PER_SEC) as libc::c_int;
}
#[inline]
pub unsafe fn timex_uint64(a: timex_t) -> uint64_t {
return (a.seconds as uint64_t)
.wrapping_mul(US_PER_SEC as libc::c_ulonglong)
.wrapping_add(a.microseconds as libc::c_ulonglong);
}
#[inline]
pub unsafe fn timex_from_uint64(timestamp: uint64_t) -> timex_t {
return timex_set(
timestamp.wrapping_div(US_PER_SEC as libc::c_ulonglong) as uint32_t,
timestamp.wrapping_rem(US_PER_SEC as libc::c_ulonglong) as uint32_t,
);
}
#[inline]
pub unsafe fn gnrc_ipv6_nib_nc_get_nud_state(
mut entry: *const gnrc_ipv6_nib_nc_t,
) -> libc::c_uint {
return ((*entry).info as libc::c_int & GNRC_IPV6_NIB_NC_INFO_NUD_STATE_MASK)
as libc::c_uint;
}
pub const GNRC_IPV6_NIB_NC_INFO_NUD_STATE_MASK: libc::c_int = 0x7 as libc::c_int;
#[inline]
pub unsafe fn gnrc_ipv6_nib_nc_is_router(
mut entry: *const gnrc_ipv6_nib_nc_t,
) -> bool {
return (*entry).info as libc::c_int & GNRC_IPV6_NIB_NC_INFO_IS_ROUTER != 0;
}
pub const GNRC_IPV6_NIB_NC_INFO_IS_ROUTER: libc::c_int = 0x8 as libc::c_int;
#[inline]
pub unsafe fn gnrc_ipv6_nib_nc_get_iface(
mut entry: *const gnrc_ipv6_nib_nc_t,
) -> libc::c_uint {
return (((*entry).info as libc::c_int & GNRC_IPV6_NIB_NC_INFO_IFACE_MASK)
>> GNRC_IPV6_NIB_NC_INFO_IFACE_POS) as libc::c_uint;
}
pub const GNRC_IPV6_NIB_NC_INFO_IFACE_POS: libc::c_int = 4 as libc::c_int;
pub const GNRC_IPV6_NIB_NC_INFO_IFACE_MASK: libc::c_int = 0x1f0 as libc::c_int;
#[inline]
pub unsafe fn gnrc_ipv6_nib_nc_get_ar_state(
mut entry: *const gnrc_ipv6_nib_nc_t,
) -> libc::c_uint {
return ((*entry).info as libc::c_int & GNRC_IPV6_NIB_NC_INFO_AR_STATE_MASK)
as libc::c_uint;
}
pub const GNRC_IPV6_NIB_NC_INFO_AR_STATE_MASK: libc::c_int = 0x600 as libc::c_int;
#[inline]
pub unsafe fn gnrc_ipv6_nib_pl_valid_offset(
mut ple: *const gnrc_ipv6_nib_pl_t,
) -> uint32_t {
return if (*ple).valid_until == UINT32_MAX {
UINT32_MAX
} else {
((*ple).valid_until).wrapping_sub(evtimer_now_msec())
};
}
#[inline]
pub unsafe fn gnrc_ipv6_nib_pl_pref_offset(
mut ple: *const gnrc_ipv6_nib_pl_t,
) -> uint32_t {
return if (*ple).pref_until == UINT32_MAX {
UINT32_MAX
} else {
((*ple).pref_until).wrapping_sub(evtimer_now_msec())
};
}
#[inline]
pub unsafe fn sock_ip_recv(
mut sock: *mut sock_ip_t,
mut data: *mut libc::c_void,
mut max_len: size_t,
mut timeout: uint32_t,
mut remote: *mut sock_ip_ep_t,
) -> ssize_t {
return sock_ip_recv_aux(
sock,
data,
max_len,
timeout,
remote,
NULL_1 as *mut sock_ip_aux_rx_t,
);
}
#[inline]
pub unsafe fn sock_ip_recv_buf(
mut sock: *mut sock_ip_t,
mut data: *mut *mut libc::c_void,
mut buf_ctx: *mut *mut libc::c_void,
mut timeout: uint32_t,
mut remote: *mut sock_ip_ep_t,
) -> ssize_t {
return sock_ip_recv_buf_aux(
sock,
data,
buf_ctx,
timeout,
remote,
NULL_1 as *mut sock_ip_aux_rx_t,
);
}
#[inline]
pub unsafe fn sock_ip_send(
mut sock: *mut sock_ip_t,
mut data: *const libc::c_void,
mut len: size_t,
mut proto: uint8_t,
mut remote: *const sock_ip_ep_t,
) -> ssize_t {
return sock_ip_send_aux(
sock,
data,
len,
proto,
remote,
NULL_1 as *mut sock_ip_aux_tx_t,
);
}
#[inline]
pub unsafe fn bitarithm_msb(mut v: libc::c_uint) -> libc::c_uint {
return (8 as libc::c_int as libc::c_uint)
.wrapping_mul(::core::mem::size_of::<libc::c_uint>() as libc::c_ulong)
.wrapping_sub(v.leading_zeros() as i32 as libc::c_uint)
.wrapping_sub(1 as libc::c_int as libc::c_uint);
}
#[inline]
pub unsafe fn bitarithm_lsb(mut v: libc::c_uint) -> libc::c_uint {
return (if v as libc::c_int == 0 {
0
} else {
(v as libc::c_int).trailing_zeros() as i32 + 1
} - 1 as libc::c_int) as libc::c_uint;
}
#[inline]
pub unsafe fn bitarithm_bits_set_u32(mut v: uint32_t) -> uint8_t {
return bitarithm_bits_set(v) as uint8_t;
}
#[inline]
pub unsafe fn bitarithm_clzb(mut x: uint8_t) -> uint8_t {
return ((x as libc::c_uint).leading_zeros() as i32 as libc::c_uint)
.wrapping_sub(
(8 as libc::c_int as libc::c_uint)
.wrapping_mul(
(::core::mem::size_of::<libc::c_uint>() as libc::c_ulong)
.wrapping_sub(1 as libc::c_int as libc::c_uint),
),
) as uint8_t;
}
#[inline]
pub unsafe fn bitarithm_test_and_clear(
mut state: libc::c_uint,
mut index: *mut uint8_t,
) -> libc::c_uint {
*index = (8 as libc::c_int as libc::c_uint)
.wrapping_mul(::core::mem::size_of::<libc::c_uint>() as libc::c_ulong)
.wrapping_sub(state.leading_zeros() as i32 as libc::c_uint)
.wrapping_sub(1 as libc::c_int as libc::c_uint) as uint8_t;
return state & !((1 as libc::c_int) << *index as libc::c_int) as libc::c_uint;
}
#[inline]
pub unsafe fn bf_set(mut field: *mut uint8_t, mut idx: size_t) {
let ref mut fresh48 = *field
.offset(idx.wrapping_div(8 as libc::c_int as libc::c_uint) as isize);
*fresh48 = (*fresh48 as libc::c_uint
| (1 as libc::c_uint)
<< (7 as libc::c_int as libc::c_uint)
.wrapping_sub(idx.wrapping_rem(8 as libc::c_int as libc::c_uint)))
as uint8_t;
}
#[inline]
pub unsafe fn bf_set_atomic(mut field: *mut uint8_t, mut idx: size_t) {
let mut state: libc::c_uint = irq_disable();
bf_set(field, idx);
irq_restore(state);
}
#[inline]
pub unsafe fn bf_unset(mut field: *mut uint8_t, mut idx: size_t) {
let ref mut fresh49 = *field
.offset(idx.wrapping_div(8 as libc::c_int as libc::c_uint) as isize);
*fresh49 = (*fresh49 as libc::c_uint
& !((1 as libc::c_uint)
<< (7 as libc::c_int as libc::c_uint)
.wrapping_sub(idx.wrapping_rem(8 as libc::c_int as libc::c_uint))))
as uint8_t;
}
#[inline]
pub unsafe fn bf_unset_atomic(mut field: *mut uint8_t, mut idx: size_t) {
let mut state: libc::c_uint = irq_disable();
bf_unset(field, idx);
irq_restore(state);
}
#[inline]
pub unsafe fn bf_toggle(mut field: *mut uint8_t, mut idx: size_t) {
let ref mut fresh50 = *field
.offset(idx.wrapping_div(8 as libc::c_int as libc::c_uint) as isize);
*fresh50 = (*fresh50 as libc::c_uint
^ (1 as libc::c_uint)
<< (7 as libc::c_int as libc::c_uint)
.wrapping_sub(idx.wrapping_rem(8 as libc::c_int as libc::c_uint)))
as uint8_t;
}
#[inline]
pub unsafe fn bf_toggle_atomic(mut field: *mut uint8_t, mut idx: size_t) {
let mut state: libc::c_uint = irq_disable();
bf_toggle(field, idx);
irq_restore(state);
}
#[inline]
pub unsafe fn bf_isset(mut field: *const uint8_t, mut idx: size_t) -> bool {
return *field.offset(idx.wrapping_div(8 as libc::c_int as libc::c_uint) as isize)
as libc::c_uint
& (1 as libc::c_uint)
<< (7 as libc::c_int as libc::c_uint)
.wrapping_sub(idx.wrapping_rem(8 as libc::c_int as libc::c_uint)) != 0;
}
#[inline]
pub unsafe fn bf_or(
mut out: *mut uint8_t,
mut a: *const uint8_t,
mut b: *const uint8_t,
mut len: size_t,
) {
len = len
.wrapping_add(7 as libc::c_int as libc::c_uint)
.wrapping_div(8 as libc::c_int as libc::c_uint);
loop {
let fresh51 = len;
len = len.wrapping_sub(1);
if !(fresh51 != 0) {
break;
}
*out
.offset(
len as isize,
) = (*a.offset(len as isize) as libc::c_int
| *b.offset(len as isize) as libc::c_int) as uint8_t;
};
}
#[inline]
pub unsafe fn bf_or_atomic(
mut out: *mut uint8_t,
mut a: *const uint8_t,
mut b: *const uint8_t,
mut len: size_t,
) {
let mut state: libc::c_uint = irq_disable();
bf_or(out, a, b, len);
irq_restore(state);
}
#[inline]
pub unsafe fn bf_and(
mut out: *mut uint8_t,
mut a: *const uint8_t,
mut b: *const uint8_t,
mut len: size_t,
) {
len = len
.wrapping_add(7 as libc::c_int as libc::c_uint)
.wrapping_div(8 as libc::c_int as libc::c_uint);
loop {
let fresh52 = len;
len = len.wrapping_sub(1);
if !(fresh52 != 0) {
break;
}
*out
.offset(
len as isize,
) = (*a.offset(len as isize) as libc::c_int
& *b.offset(len as isize) as libc::c_int) as uint8_t;
};
}
#[inline]
pub unsafe fn bf_and_atomic(
mut out: *mut uint8_t,
mut a: *const uint8_t,
mut b: *const uint8_t,
mut len: size_t,
) {
let mut state: libc::c_uint = irq_disable();
bf_and(out, a, b, len);
irq_restore(state);
}
#[inline]
pub unsafe fn bf_xor(
mut out: *mut uint8_t,
mut a: *const uint8_t,
mut b: *const uint8_t,
mut len: size_t,
) {
len = len
.wrapping_add(7 as libc::c_int as libc::c_uint)
.wrapping_div(8 as libc::c_int as libc::c_uint);
loop {
let fresh53 = len;
len = len.wrapping_sub(1);
if !(fresh53 != 0) {
break;
}
*out
.offset(
len as isize,
) = (*a.offset(len as isize) as libc::c_int
^ *b.offset(len as isize) as libc::c_int) as uint8_t;
};
}
#[inline]
pub unsafe fn bf_xor_atomic(
mut out: *mut uint8_t,
mut a: *const uint8_t,
mut b: *const uint8_t,
mut len: size_t,
) {
let mut state: libc::c_uint = irq_disable();
bf_xor(out, a, b, len);
irq_restore(state);
}
#[inline]
pub unsafe fn bf_inv(
mut out: *mut uint8_t,
mut a: *const uint8_t,
mut len: size_t,
) {
len = len
.wrapping_add(7 as libc::c_int as libc::c_uint)
.wrapping_div(8 as libc::c_int as libc::c_uint);
loop {
let fresh54 = len;
len = len.wrapping_sub(1);
if !(fresh54 != 0) {
break;
}
*out.offset(len as isize) = !(*a.offset(len as isize) as libc::c_int) as uint8_t;
};
}
#[inline]
pub unsafe fn bf_inv_atomic(
mut out: *mut uint8_t,
mut a: *const uint8_t,
mut len: size_t,
) {
let mut state: libc::c_uint = irq_disable();
bf_inv(out, a, len);
irq_restore(state);
}
#[inline]
pub unsafe fn bf_set_all_atomic(mut field: *mut uint8_t, mut size: size_t) {
let mut state: libc::c_uint = irq_disable();
bf_set_all(field, size);
irq_restore(state);
}
#[inline]
pub unsafe fn bf_clear_all_atomic(mut field: *mut uint8_t, mut size: size_t) {
let mut state: libc::c_uint = irq_disable();
bf_clear_all(field, size);
irq_restore(state);
}
#[inline]
pub unsafe fn coap_hdr_data_ptr(mut hdr: *const coap_hdr_t) -> *mut uint8_t {
return (hdr as *mut uint8_t)
.offset(::core::mem::size_of::<coap_hdr_t>() as libc::c_ulong as isize)
.offset(coap_hdr_tkl_ext_len(hdr) as libc::c_int as isize);
}
#[inline]
pub unsafe fn coap_hdr_tkl_ext_len(mut hdr: *const coap_hdr_t) -> uint8_t {
if 0 as libc::c_int == 0 {
return 0 as libc::c_int as uint8_t;
}
match (*hdr).ver_t_tkl as libc::c_int & 0xf as libc::c_int {
13 => return 1 as libc::c_int as uint8_t,
14 => return 2 as libc::c_int as uint8_t,
15 => {
if 0 as libc::c_int as uintptr_t as libc::c_long != 0 {} else {
_assert_panic();
};
}
_ => {}
}
return 0 as libc::c_int as uint8_t;
}
#[inline]
pub unsafe fn coap_hdr_get_token_len(mut hdr: *const coap_hdr_t) -> size_t {
let mut buf: *const uint8_t = hdr as *const libc::c_void as *const uint8_t;
match coap_hdr_tkl_ext_len(hdr) as libc::c_int {
0 => return ((*hdr).ver_t_tkl as libc::c_int & 0xf as libc::c_int) as size_t,
1 => {
return (*buf
.offset(::core::mem::size_of::<coap_hdr_t>() as libc::c_ulong as isize)
as libc::c_int + 13 as libc::c_int) as size_t;
}
2 => {
return (byteorder_bebuftohs(
buf
.offset(
::core::mem::size_of::<coap_hdr_t>() as libc::c_ulong as isize,
),
) as libc::c_int + 269 as libc::c_int) as size_t;
}
_ => {}
}
return 0 as libc::c_int as size_t;
}
#[inline]
pub unsafe fn coap_code(
mut cls: libc::c_uint,
mut detail: libc::c_uint,
) -> uint8_t {
return (cls << 5 as libc::c_int | detail) as uint8_t;
}
#[inline]
pub unsafe fn coap_get_code_class(mut pkt: *const coap_pkt_t) -> libc::c_uint {
return ((*(*pkt).hdr).code as libc::c_int >> 5 as libc::c_int) as libc::c_uint;
}
#[inline]
pub unsafe fn coap_get_code_detail(mut pkt: *const coap_pkt_t) -> libc::c_uint {
return ((*(*pkt).hdr).code as libc::c_int & 0x1f as libc::c_int) as libc::c_uint;
}
#[inline]
pub unsafe fn coap_get_code_decimal(mut pkt: *const coap_pkt_t) -> libc::c_uint {
return (coap_get_code_class(pkt))
.wrapping_mul(100 as libc::c_int as libc::c_uint)
.wrapping_add(coap_get_code_detail(pkt));
}
#[inline]
pub unsafe fn coap_get_code_raw(mut pkt: *const coap_pkt_t) -> libc::c_uint {
return (*(*pkt).hdr).code as libc::c_uint;
}
#[inline]
pub unsafe fn coap_get_method(mut pkt: *const coap_pkt_t) -> coap_method_t {
return (*(*pkt).hdr).code as coap_method_t;
}
#[inline]
pub unsafe fn coap_get_id(mut pkt: *const coap_pkt_t) -> libc::c_uint {
return ntohs((*(*pkt).hdr).id) as libc::c_uint;
}
#[inline]
pub unsafe fn coap_get_token_len(mut pkt: *const coap_pkt_t) -> libc::c_uint {
return coap_hdr_get_token_len((*pkt).hdr);
}
#[inline]
pub unsafe fn coap_get_token(mut pkt: *const coap_pkt_t) -> *mut libc::c_void {
return coap_hdr_data_ptr((*pkt).hdr) as *mut libc::c_void;
}
#[inline]
pub unsafe fn coap_get_total_len(mut pkt: *const coap_pkt_t) -> libc::c_uint {
return ((*pkt).payload as uintptr_t)
.wrapping_sub((*pkt).hdr as uintptr_t)
.wrapping_add((*pkt).payload_len as libc::c_uint);
}
#[inline]
pub unsafe fn coap_get_type(mut pkt: *const coap_pkt_t) -> libc::c_uint {
return (((*(*pkt).hdr).ver_t_tkl as libc::c_int & 0x30 as libc::c_int)
>> 4 as libc::c_int) as libc::c_uint;
}
#[inline]
pub unsafe fn coap_get_ver(mut pkt: *const coap_pkt_t) -> libc::c_uint {
return (((*(*pkt).hdr).ver_t_tkl as libc::c_int & 0x60 as libc::c_int)
>> 6 as libc::c_int) as libc::c_uint;
}
#[inline]
pub unsafe fn coap_get_total_hdr_len(mut pkt: *const coap_pkt_t) -> libc::c_uint {
return (::core::mem::size_of::<coap_hdr_t>() as libc::c_ulong)
.wrapping_add(coap_hdr_tkl_ext_len((*pkt).hdr) as libc::c_uint)
.wrapping_add(coap_get_token_len(pkt));
}
#[inline]
pub unsafe fn coap_get_response_hdr_len(
mut pkt: *const coap_pkt_t,
) -> libc::c_uint {
return coap_get_total_hdr_len(pkt);
}
#[inline]
pub unsafe fn coap_hdr_set_code(mut hdr: *mut coap_hdr_t, mut code: uint8_t) {
(*hdr).code = code;
}
#[inline]
pub unsafe fn coap_pkt_set_code(mut pkt: *mut coap_pkt_t, mut code: uint8_t) {
coap_hdr_set_code((*pkt).hdr, code);
}
#[inline]
pub unsafe fn coap_hdr_set_type(
mut hdr: *mut coap_hdr_t,
mut type_0: libc::c_uint,
) {
if (type_0 & !(0x3 as libc::c_int) as libc::c_uint == 0) as libc::c_int as uintptr_t
as libc::c_long != 0
{} else {
_assert_panic();
};
(*hdr)
.ver_t_tkl = ((*hdr).ver_t_tkl as libc::c_int & !(0x30 as libc::c_int))
as uint8_t;
(*hdr)
.ver_t_tkl = ((*hdr).ver_t_tkl as libc::c_uint | type_0 << 4 as libc::c_int)
as uint8_t;
}
#[inline]
pub unsafe fn coap_hdr_len(mut hdr: *const coap_hdr_t) -> size_t {
return (::core::mem::size_of::<coap_hdr_t>() as libc::c_ulong)
.wrapping_add(coap_hdr_tkl_ext_len(hdr) as libc::c_uint)
.wrapping_add(coap_hdr_get_token_len(hdr));
}
#[inline]
pub unsafe fn coap_get_location_path(
mut pkt: *mut coap_pkt_t,
mut target: *mut uint8_t,
mut max_len: size_t,
) -> ssize_t {
return coap_opt_get_string(
pkt,
COAP_OPT_LOCATION_PATH as uint16_t,
target,
max_len,
'/' as i32 as libc::c_char,
);
}
pub const COAP_OPT_LOCATION_PATH: libc::c_int = 8 as libc::c_int;
#[inline]
pub unsafe fn coap_get_location_query(
mut pkt: *mut coap_pkt_t,
mut target: *mut uint8_t,
mut max_len: size_t,
) -> ssize_t {
return coap_opt_get_string(
pkt,
COAP_OPT_LOCATION_QUERY as uint16_t,
target,
max_len,
'&' as i32 as libc::c_char,
);
}
pub const COAP_OPT_LOCATION_QUERY: libc::c_int = 20 as libc::c_int;
#[inline]
pub unsafe fn coap_get_uri_path(
mut pkt: *mut coap_pkt_t,
mut target: *mut uint8_t,
) -> ssize_t {
return coap_opt_get_string(
pkt,
COAP_OPT_URI_PATH as uint16_t,
target,
CONFIG_NANOCOAP_URI_MAX as size_t,
'/' as i32 as libc::c_char,
);
}
pub const CONFIG_NANOCOAP_URI_MAX: libc::c_int = 64 as libc::c_int;
pub const COAP_OPT_URI_PATH: libc::c_int = 11 as libc::c_int;
#[inline]
pub unsafe fn coap_get_uri_query_string(
mut pkt: *mut coap_pkt_t,
mut target: *mut libc::c_char,
mut max_len: size_t,
) -> ssize_t {
return coap_opt_get_string(
pkt,
COAP_OPT_URI_QUERY as uint16_t,
target as *mut uint8_t,
max_len,
'&' as i32 as libc::c_char,
);
}
pub const COAP_OPT_URI_QUERY: libc::c_int = 15 as libc::c_int;
#[inline]
pub unsafe fn coap_get_proxy_uri(
mut pkt: *mut coap_pkt_t,
mut target: *mut *mut libc::c_char,
) -> ssize_t {
return coap_opt_get_opaque(
pkt,
COAP_OPT_PROXY_URI as libc::c_uint,
target as *mut *mut uint8_t,
);
}
pub const COAP_OPT_PROXY_URI: libc::c_int = 35 as libc::c_int;
#[inline]
pub unsafe fn coap_block1_finish(mut slicer: *mut coap_block_slicer_t) -> bool {
return coap_block_finish(slicer, COAP_OPT_BLOCK1 as uint16_t);
}
pub const COAP_OPT_BLOCK1: libc::c_int = 27 as libc::c_int;
#[inline]
pub unsafe fn coap_block2_finish(mut slicer: *mut coap_block_slicer_t) -> bool {
return coap_block_finish(slicer, COAP_OPT_BLOCK2 as uint16_t);
}
pub const COAP_OPT_BLOCK2: libc::c_int = 23 as libc::c_int;
#[inline]
pub unsafe fn coap_get_block1(
mut pkt: *mut coap_pkt_t,
mut block: *mut coap_block1_t,
) -> libc::c_int {
return coap_get_block(pkt, block, COAP_OPT_BLOCK1 as uint16_t);
}
#[inline]
pub unsafe fn coap_get_block2(
mut pkt: *mut coap_pkt_t,
mut block: *mut coap_block1_t,
) -> libc::c_int {
return coap_get_block(pkt, block, COAP_OPT_BLOCK2 as uint16_t);
}
#[inline]
pub unsafe fn coap_size2szx(mut len: libc::c_uint) -> libc::c_uint {
if (len >= 16 as libc::c_int as libc::c_uint) as libc::c_int as uintptr_t
as libc::c_long != 0
{} else {
_assert_panic();
};
return bitarithm_msb(len >> 4 as libc::c_int);
}
#[inline]
pub unsafe fn coap_opt_add_block1(
mut pkt: *mut coap_pkt_t,
mut slicer: *mut coap_block_slicer_t,
mut more: bool,
) -> ssize_t {
return coap_opt_add_block(pkt, slicer, more, COAP_OPT_BLOCK1 as uint16_t);
}
#[inline]
pub unsafe fn coap_opt_add_block2(
mut pkt: *mut coap_pkt_t,
mut slicer: *mut coap_block_slicer_t,
mut more: bool,
) -> ssize_t {
return coap_opt_add_block(pkt, slicer, more, COAP_OPT_BLOCK2 as uint16_t);
}
#[inline]
pub unsafe fn coap_opt_add_block1_control(
mut pkt: *mut coap_pkt_t,
mut block: *mut coap_block1_t,
) -> ssize_t {
return coap_opt_add_uint(
pkt,
COAP_OPT_BLOCK1 as uint16_t,
(*block).blknum << 4 as libc::c_int | (*block).szx as libc::c_uint
| (if (*block).more as libc::c_int != 0 {
0x8 as libc::c_int
} else {
0 as libc::c_int
}) as libc::c_uint,
);
}
#[inline]
pub unsafe fn coap_opt_add_block2_control(
mut pkt: *mut coap_pkt_t,
mut block: *mut coap_block1_t,
) -> ssize_t {
return coap_opt_add_uint(
pkt,
COAP_OPT_BLOCK2 as uint16_t,
(*block).blknum << 4 as libc::c_int | (*block).szx as libc::c_uint,
);
}
#[inline]
pub unsafe fn coap_opt_add_accept(
mut pkt: *mut coap_pkt_t,
mut format: uint16_t,
) -> ssize_t {
return coap_opt_add_uint(pkt, COAP_OPT_ACCEPT as uint16_t, format as uint32_t);
}
pub const COAP_OPT_ACCEPT: libc::c_int = 17 as libc::c_int;
#[inline]
pub unsafe fn coap_opt_add_format(
mut pkt: *mut coap_pkt_t,
mut format: uint16_t,
) -> ssize_t {
return coap_opt_add_uint(
pkt,
COAP_OPT_CONTENT_FORMAT as uint16_t,
format as uint32_t,
);
}
pub const COAP_OPT_CONTENT_FORMAT: libc::c_int = 12 as libc::c_int;
#[inline]
pub unsafe fn coap_opt_add_uri_query(
mut pkt: *mut coap_pkt_t,
mut key: *const libc::c_char,
mut val: *const libc::c_char,
) -> ssize_t {
return coap_opt_add_uri_query2(
pkt,
key,
strlen(key),
val,
if !val.is_null() { strlen(val) } else { 0 as libc::c_int as libc::c_uint },
);
}
#[inline]
pub unsafe fn coap_opt_add_string(
mut pkt: *mut coap_pkt_t,
mut optnum: uint16_t,
mut string: *const libc::c_char,
mut separator: libc::c_char,
) -> ssize_t {
return coap_opt_add_chars(pkt, optnum, string, strlen(string), separator);
}
#[inline]
pub unsafe fn coap_opt_add_uri_path(
mut pkt: *mut coap_pkt_t,
mut path: *const libc::c_char,
) -> ssize_t {
return coap_opt_add_string(
pkt,
COAP_OPT_URI_PATH as uint16_t,
path,
'/' as i32 as libc::c_char,
);
}
#[inline]
pub unsafe fn coap_opt_add_uri_path_buffer(
mut pkt: *mut coap_pkt_t,
mut path: *const libc::c_char,
mut path_len: size_t,
) -> ssize_t {
return coap_opt_add_chars(
pkt,
COAP_OPT_URI_PATH as uint16_t,
path,
path_len,
'/' as i32 as libc::c_char,
);
}
#[inline]
pub unsafe fn coap_opt_put_block1(
mut buf: *mut uint8_t,
mut lastonum: uint16_t,
mut slicer: *mut coap_block_slicer_t,
mut more: bool,
) -> size_t {
return coap_opt_put_block(buf, lastonum, slicer, more, COAP_OPT_BLOCK1 as uint16_t);
}
#[inline]
pub unsafe fn coap_opt_put_block2(
mut buf: *mut uint8_t,
mut lastonum: uint16_t,
mut slicer: *mut coap_block_slicer_t,
mut more: bool,
) -> size_t {
return coap_opt_put_block(buf, lastonum, slicer, more, COAP_OPT_BLOCK2 as uint16_t);
}
#[inline]
pub unsafe fn coap_opt_put_block1_control(
mut buf: *mut uint8_t,
mut lastonum: uint16_t,
mut block: *mut coap_block1_t,
) -> size_t {
return coap_opt_put_uint(
buf,
lastonum,
COAP_OPT_BLOCK1 as uint16_t,
(*block).blknum << 4 as libc::c_int | (*block).szx as libc::c_uint
| (if (*block).more as libc::c_int != 0 {
0x8 as libc::c_int
} else {
0 as libc::c_int
}) as libc::c_uint,
);
}
#[inline]
pub unsafe fn coap_opt_put_block2_control(
mut buf: *mut uint8_t,
mut lastonum: uint16_t,
mut block: *mut coap_block1_t,
) -> size_t {
return coap_opt_put_uint(
buf,
lastonum,
COAP_OPT_BLOCK2 as uint16_t,
(*block).blknum << 4 as libc::c_int | (*block).szx as libc::c_uint,
);
}
#[inline]
pub unsafe fn coap_opt_put_string(
mut buf: *mut uint8_t,
mut lastonum: uint16_t,
mut optnum: uint16_t,
mut string: *const libc::c_char,
mut separator: libc::c_char,
) -> size_t {
return coap_opt_put_string_with_len(
buf,
lastonum,
optnum,
string,
strlen(string),
separator,
);
}
#[inline]
pub unsafe fn coap_opt_put_location_path(
mut buf: *mut uint8_t,
mut lastonum: uint16_t,
mut location: *const libc::c_char,
) -> size_t {
return coap_opt_put_string(
buf,
lastonum,
COAP_OPT_LOCATION_PATH as uint16_t,
location,
'/' as i32 as libc::c_char,
);
}
#[inline]
pub unsafe fn coap_opt_put_location_query(
mut buf: *mut uint8_t,
mut lastonum: uint16_t,
mut location: *const libc::c_char,
) -> size_t {
return coap_opt_put_string(
buf,
lastonum,
COAP_OPT_LOCATION_QUERY as uint16_t,
location,
'&' as i32 as libc::c_char,
);
}
#[inline]
pub unsafe fn coap_opt_put_uri_path(
mut buf: *mut uint8_t,
mut lastonum: uint16_t,
mut uri: *const libc::c_char,
) -> size_t {
return coap_opt_put_string(
buf,
lastonum,
COAP_OPT_URI_PATH as uint16_t,
uri,
'/' as i32 as libc::c_char,
);
}
#[inline]
pub unsafe fn coap_opt_put_uri_query(
mut buf: *mut uint8_t,
mut lastonum: uint16_t,
mut uri: *const libc::c_char,
) -> size_t {
return coap_opt_put_string(
buf,
lastonum,
COAP_OPT_URI_QUERY as uint16_t,
uri,
'&' as i32 as libc::c_char,
);
}
#[inline]
pub unsafe fn coap_opt_put_proxy_uri(
mut buf: *mut uint8_t,
mut lastonum: uint16_t,
mut uri: *const libc::c_char,
) -> size_t {
return coap_opt_put_string(
buf,
lastonum,
COAP_OPT_PROXY_URI as uint16_t,
uri,
'\0' as i32 as libc::c_char,
);
}
#[inline]
pub unsafe fn coap_put_option_block1(
mut buf: *mut uint8_t,
mut lastonum: uint16_t,
mut blknum: libc::c_uint,
mut szx: libc::c_uint,
mut more: libc::c_int,
) -> size_t {
return coap_opt_put_uint(
buf,
lastonum,
COAP_OPT_BLOCK1 as uint16_t,
blknum << 4 as libc::c_int | szx
| (if more != 0 { 0x8 as libc::c_int } else { 0 as libc::c_int })
as libc::c_uint,
);
}
#[inline]
pub unsafe fn coap_put_option_ct(
mut buf: *mut uint8_t,
mut lastonum: uint16_t,
mut content_type: uint16_t,
) -> size_t {
return coap_opt_put_uint(
buf,
lastonum,
COAP_OPT_CONTENT_FORMAT as uint16_t,
content_type as uint32_t,
);
}
#[inline]
pub unsafe fn sha256_update(
mut ctx: *mut sha256_context_t,
mut data: *const libc::c_void,
mut len: size_t,
) {
sha2xx_update(ctx, data, len);
}
#[inline]
pub unsafe fn sha256_final(
mut ctx: *mut sha256_context_t,
mut digest: *mut libc::c_void,
) {
sha2xx_final(ctx, digest, SHA256_DIGEST_LENGTH as size_t);
}
pub const SHA256_DIGEST_LENGTH: libc::c_int = 32 as libc::c_int;
#[inline]
pub unsafe fn nanocoap_cache_init() {}
#[inline]
pub unsafe fn nanocoap_cache_entry_is_stale(
mut ce: *const nanocoap_cache_entry_t,
mut now: uint32_t,
) -> bool {
return now.wrapping_sub((*ce).max_age) as libc::c_int > 0 as libc::c_int;
}
#[inline]
pub unsafe fn gcoap_req_init(
mut pdu: *mut coap_pkt_t,
mut buf: *mut uint8_t,
mut len: size_t,
mut code: libc::c_uint,
mut path: *const libc::c_char,
) -> libc::c_int {
return gcoap_req_init_path_buffer(
pdu,
buf,
len,
code,
path,
if !path.is_null() { strlen(path) } else { 0 as libc::c_uint },
);
}
#[inline]
pub unsafe fn gcoap_request(
mut pdu: *mut coap_pkt_t,
mut buf: *mut uint8_t,
mut len: size_t,
mut code: libc::c_uint,
mut path: *mut libc::c_char,
) -> ssize_t {
if gcoap_req_init(pdu, buf, len, code, path) == 0 as libc::c_int {
return coap_opt_finish(pdu, COAP_OPT_FINISH_NONE as uint16_t);
}
return -(1 as libc::c_int);
}
pub const COAP_OPT_FINISH_NONE: libc::c_int = 0 as libc::c_int;
pub const COAP_OPT_ETAG: libc::c_int = 4 as libc::c_int;
#[inline]
pub unsafe fn gcoap_req_send_tl(
mut buf: *const uint8_t,
mut len: size_t,
mut remote: *const sock_udp_ep_t,
mut resp_handler: gcoap_resp_handler_t,
mut context: *mut libc::c_void,
mut tl_type: gcoap_socket_type_t,
) -> ssize_t {
return gcoap_req_send(
buf,
len,
remote,
NULL_1 as *const sock_udp_ep_t,
resp_handler,
context,
tl_type,
);
}
#[inline]
pub unsafe fn gcoap_response(
mut pdu: *mut coap_pkt_t,
mut buf: *mut uint8_t,
mut len: size_t,
mut code: libc::c_uint,
) -> ssize_t {
return if gcoap_resp_init(pdu, buf, len, code) == 0 as libc::c_int {
coap_opt_finish(pdu, COAP_OPT_FINISH_NONE as uint16_t)
} else {
-(1 as libc::c_int)
};
}
#[inline]
pub unsafe fn gcoap_request_memo_get_hdr(
mut memo: *const gcoap_request_memo_t,
) -> *mut coap_hdr_t {
if (*memo).send_limit == GCOAP_SEND_LIMIT_NON {
return &*((*memo).msg.hdr_buf).as_ptr().offset(0 as libc::c_int as isize)
as *const uint8_t as *mut coap_hdr_t
} else {
return (*memo).msg.data.pdu_buf as *mut coap_hdr_t
};
}
pub const GCOAP_SEND_LIMIT_NON: libc::c_int = -(1 as libc::c_int);
#[inline]
pub unsafe fn __sputc_r(
mut _ptr: *mut _reent,
mut _c: libc::c_int,
mut _p: *mut FILE,
) -> libc::c_int {
(*_p)._w -= 1;
if (*_p)._w >= 0 as libc::c_int
|| (*_p)._w >= (*_p)._lbfsize && _c as libc::c_char as libc::c_int != '\n' as i32
{
let fresh55 = (*_p)._p;
(*_p)._p = ((*_p)._p).offset(1);
*fresh55 = _c as libc::c_uchar;
return *fresh55 as libc::c_int;
} else {
return __swbuf_r(_ptr, _c, _p)
};
}
#[inline]
pub unsafe fn _getchar_unlocked() -> libc::c_int {
let mut _ptr: *mut _reent = 0 as *mut _reent;
_ptr = _impure_ptr;
(*(*_ptr)._stdin)._r -= 1;
return if (*(*_ptr)._stdin)._r < 0 as libc::c_int {
__srget_r(_ptr, (*_ptr)._stdin)
} else {
let fresh56 = (*(*_ptr)._stdin)._p;
(*(*_ptr)._stdin)._p = ((*(*_ptr)._stdin)._p).offset(1);
*fresh56 as libc::c_int
};
}
#[inline]
pub unsafe fn _putchar_unlocked(mut _c: libc::c_int) -> libc::c_int {
let mut _ptr: *mut _reent = 0 as *mut _reent;
_ptr = _impure_ptr;
return __sputc_r(_ptr, _c, (*_ptr)._stdout);
}
#[inline]
pub unsafe fn sha224_update(
mut ctx: *mut sha224_context_t,
mut data: *const libc::c_void,
mut len: size_t,
) {
sha2xx_update(ctx, data, len);
}
#[inline]
pub unsafe fn sha224_final(
mut ctx: *mut sha224_context_t,
mut digest: *mut libc::c_void,
) {
sha2xx_final(ctx, digest, SHA224_DIGEST_LENGTH as size_t);
}
pub const SHA224_DIGEST_LENGTH: libc::c_int = 28 as libc::c_int;
#[inline]
pub unsafe fn sha512_update(
mut ctx: *mut sha512_context_t,
mut data: *const libc::c_void,
mut len: size_t,
) {
sha512_common_update(ctx, data, len);
}
#[inline]
pub unsafe fn sha512_final(
mut ctx: *mut sha512_context_t,
mut digest: *mut libc::c_void,
) {
sha512_common_final(ctx, digest, SHA512_DIGEST_LENGTH as size_t);
}
pub const SHA512_DIGEST_LENGTH: libc::c_int = 64 as libc::c_int;
#[inline]
pub unsafe fn sock_tcp_ep_fmt(
mut endpoint: *const sock_tcp_ep_t,
mut addr_str: *mut libc::c_char,
mut port: *mut uint16_t,
) -> libc::c_int {
return sock_tl_ep_fmt(endpoint, addr_str, port);
}
#[inline]
pub unsafe fn sock_udp_ep_fmt(
mut endpoint: *const sock_udp_ep_t,
mut addr_str: *mut libc::c_char,
mut port: *mut uint16_t,
) -> libc::c_int {
return sock_tl_ep_fmt(endpoint, addr_str, port);
}
#[inline]
pub unsafe fn sock_tcp_str2ep(
mut ep_out: *mut sock_tcp_ep_t,
mut str: *const libc::c_char,
) -> libc::c_int {
return sock_tl_str2ep(ep_out, str);
}
#[inline]
pub unsafe fn sock_tcp_name2ep(
mut ep_out: *mut sock_tcp_ep_t,
mut str: *const libc::c_char,
) -> libc::c_int {
return sock_tl_name2ep(ep_out, str);
}
#[inline]
pub unsafe fn sock_udp_str2ep(
mut ep_out: *mut sock_udp_ep_t,
mut str: *const libc::c_char,
) -> libc::c_int {
return sock_tl_str2ep(ep_out, str);
}
#[inline]
pub unsafe fn sock_udp_name2ep(
mut ep_out: *mut sock_udp_ep_t,
mut str: *const libc::c_char,
) -> libc::c_int {
return sock_tl_name2ep(ep_out, str);
}
#[inline]
pub unsafe fn sock_tcp_ep_equal(
mut a: *const sock_tcp_ep_t,
mut b: *const sock_tcp_ep_t,
) -> bool {
return sock_tl_ep_equal(a, b);
}
#[inline]
pub unsafe fn sock_udp_ep_equal(
mut a: *const sock_udp_ep_t,
mut b: *const sock_udp_ep_t,
) -> bool {
return sock_tl_ep_equal(a, b);
}
#[inline]
pub unsafe fn nanocoap_sock_next_msg_id(
mut sock: *mut nanocoap_sock_t,
) -> uint16_t {
let fresh57 = (*sock).msg_id;
(*sock).msg_id = ((*sock).msg_id).wrapping_add(1);
return fresh57;
}
#[inline]
pub unsafe fn nanocoap_sock_connect(
mut sock: *mut nanocoap_sock_t,
mut local: *const sock_udp_ep_t,
mut remote: *const sock_udp_ep_t,
) -> libc::c_int {
(*sock).msg_id = random_uint32() as uint16_t;
return sock_udp_create(
&mut (*sock).udp,
local,
remote,
0 as libc::c_int as uint16_t,
);
}
#[inline]
pub unsafe fn nanocoap_sock_close(mut sock: *mut nanocoap_sock_t) {
sock_udp_close(&mut (*sock).udp);
}
#[inline]
pub unsafe fn nanocoap_block_request_connect_url(
mut ctx: *mut coap_block_request_t,
mut sock: *mut nanocoap_sock_t,
mut url: *const libc::c_char,
mut method: coap_method_t,
mut blksize: coap_blksize_t,
) -> libc::c_int {
(*ctx).sock = sock;
(*ctx).path = sock_urlpath(url);
(*ctx).blknum = 0 as libc::c_int as uint32_t;
(*ctx).method = method;
(*ctx).blksize = blksize as uint8_t;
return nanocoap_sock_url_connect(url, (*ctx).sock);
}
#[inline]
pub unsafe fn tsrb_init(
mut rb: *mut tsrb_t,
mut buffer: *mut uint8_t,
mut bufsize: libc::c_uint,
) {
if (bufsize != 0 as libc::c_int as libc::c_uint
&& bufsize & (!bufsize).wrapping_add(1 as libc::c_int as libc::c_uint)
== bufsize) as libc::c_int as uintptr_t as libc::c_long != 0
{} else {
_assert_panic();
};
(*rb).buf = buffer;
(*rb).size = bufsize;
(*rb).reads = 0 as libc::c_int as libc::c_uint;
(*rb).writes = 0 as libc::c_int as libc::c_uint;
}
#[inline]
pub unsafe fn tsrb_clear(mut rb: *mut tsrb_t) {
let mut irq_state: libc::c_uint = irq_disable();
(*rb).reads = (*rb).writes;
irq_restore(irq_state);
}
#[inline]
pub unsafe fn tsrb_empty(mut rb: *const tsrb_t) -> libc::c_int {
let mut irq_state: libc::c_uint = irq_disable();
let mut retval: libc::c_int = ((*rb).reads == (*rb).writes) as libc::c_int;
irq_restore(irq_state);
return retval;
}
#[inline]
pub unsafe fn tsrb_avail(mut rb: *const tsrb_t) -> libc::c_uint {
let mut irq_state: libc::c_uint = irq_disable();
let mut retval: libc::c_int = ((*rb).writes).wrapping_sub((*rb).reads)
as libc::c_int;
irq_restore(irq_state);
return retval as libc::c_uint;
}
#[inline]
pub unsafe fn tsrb_full(mut rb: *const tsrb_t) -> libc::c_int {
let mut irq_state: libc::c_uint = irq_disable();
let mut retval: libc::c_int = (((*rb).writes).wrapping_sub((*rb).reads)
== (*rb).size) as libc::c_int;
irq_restore(irq_state);
return retval;
}
#[inline]
pub unsafe fn tsrb_free(mut rb: *const tsrb_t) -> libc::c_uint {
let mut irq_state: libc::c_uint = irq_disable();
let mut retval: libc::c_int = ((*rb).size)
.wrapping_sub((*rb).writes)
.wrapping_add((*rb).reads) as libc::c_int;
irq_restore(irq_state);
return retval as libc::c_uint;
}
#[inline]
pub unsafe fn flash_print_str(mut flash: *const libc::c_char) {
printf(b"%s\0" as *const u8 as *const libc::c_char, flash);
}
#[inline]
pub unsafe fn shell_run_forever(
mut commands: *const shell_command_t,
mut line_buf: *mut libc::c_char,
mut len: libc::c_int,
) {
loop {
shell_run_once(commands, line_buf, len);
};
}
#[inline]
pub unsafe fn shell_run(
mut commands: *const shell_command_t,
mut line_buf: *mut libc::c_char,
mut len: libc::c_int,
) {
shell_run_forever(commands, line_buf, len);
}
#[inline]
pub unsafe fn nanocbor_container_remaining(
mut value: *const nanocbor_value_t,
) -> uint32_t {
return (*value).remaining as uint32_t;
}
#[inline]
pub unsafe fn nanocbor_array_items_remaining(
mut value: *const nanocbor_value_t,
) -> uint32_t {
return nanocbor_container_remaining(value);
}
#[inline]
pub unsafe fn nanocbor_map_items_remaining(
mut value: *const nanocbor_value_t,
) -> uint32_t {
return (nanocbor_container_remaining(value))
.wrapping_div(2 as libc::c_int as libc::c_uint);
}
#[inline]
pub unsafe fn nanocbor_container_indefinite(
mut container: *const nanocbor_value_t,
) -> bool {
return (*container).flags as libc::c_uint
== NANOCBOR_DECODER_FLAG_INDEFINITE | NANOCBOR_DECODER_FLAG_CONTAINER;
}
pub const NANOCBOR_DECODER_FLAG_CONTAINER: libc::c_uint = 0x1 as libc::c_uint;
pub const NANOCBOR_DECODER_FLAG_INDEFINITE: libc::c_uint = 0x2 as libc::c_uint;
#[inline]
pub unsafe fn nanocbor_in_container(
mut container: *const nanocbor_value_t,
) -> bool {
return (*container).flags as libc::c_uint & 0x1 as libc::c_uint != 0;
}
#[inline]
pub unsafe fn cose_signature_init(mut signature: *mut cose_signature_t) {
memset(
signature as *mut libc::c_void,
0 as libc::c_int,
::core::mem::size_of::<cose_signature_t>() as libc::c_ulong,
);
}
#[inline]
pub unsafe fn cose_signature_decode_protected_buf(
mut signature: *const cose_signature_dec_t,
mut buf: *mut *const uint8_t,
mut len: *mut size_t,
) -> bool {
return cose_cbor_decode_get_prot((*signature).buf, (*signature).len, buf, len) != 0;
}
#[inline]
pub unsafe fn cose_signature_insert_prot(
mut signature: *mut cose_signature_t,
mut hdr: *mut cose_hdr_t,
) {
cose_hdr_insert(&mut (*signature).hdrs.prot, hdr);
}
#[inline]
pub unsafe fn cose_signature_insert_unprot(
mut signature: *mut cose_signature_t,
mut hdr: *mut cose_hdr_t,
) {
cose_hdr_insert(&mut (*signature).hdrs.unprot, hdr);
}
#[inline]
pub unsafe fn cose_sign_insert_prot(
mut sign: *mut cose_sign_enc_t,
mut hdr: *mut cose_hdr_t,
) {
cose_hdr_insert(&mut (*sign).hdrs.prot, hdr);
}
#[inline]
pub unsafe fn cose_sign_insert_unprot(
mut sign: *mut cose_sign_enc_t,
mut hdr: *mut cose_hdr_t,
) {
cose_hdr_insert(&mut (*sign).hdrs.unprot, hdr);
}
#[inline]
pub unsafe fn cose_sign_signature_iter_init(
mut signature: *mut cose_signature_dec_t,
) {
cose_signature_decode_init(
signature,
NULL_2 as *const uint8_t,
0 as libc::c_int as size_t,
);
}
#[inline]
pub unsafe fn uuid_version(mut uuid: *const uuid_t) -> libc::c_uint {
let mut time_hi_vers: uint16_t = byteorder_ntohs((*uuid).time_hi);
return ((time_hi_vers as libc::c_int & 0xf000 as libc::c_int) >> 12 as libc::c_int)
as libc::c_uint;
}
#[inline]
pub unsafe fn uuid_equal(
mut uuid1: *const uuid_t,
mut uuid2: *const uuid_t,
) -> bool {
return memcmp(
uuid1 as *const libc::c_void,
uuid2 as *const libc::c_void,
::core::mem::size_of::<uuid_t>() as libc::c_ulong,
) == 0 as libc::c_int;
}
#[inline]
pub unsafe fn suit_component_set_flag(
mut component: *mut suit_component_t,
mut flag: uint16_t,
) {
(*component)
.state = ((*component).state as libc::c_int | flag as libc::c_int) as uint16_t;
}
#[inline]
pub unsafe fn suit_component_check_flag(
mut component: *mut suit_component_t,
mut flag: uint16_t,
) -> bool {
return (*component).state as libc::c_int & flag as libc::c_int != 0;
}
#[inline]
pub unsafe fn suit_coap_trigger(mut url: *const uint8_t, mut len: size_t) {
suit_worker_trigger(url as *const libc::c_char, len);
}
#[inline]
pub unsafe fn led_on(mut id: libc::c_uint) {
match id {
0 => {
gpio_clear(LED0_PIN as gpio_t);
}
1 => {
gpio_clear(LED1_PIN as gpio_t);
}
2 => {
gpio_clear(LED2_PIN as gpio_t);
}
3 => {
gpio_clear(LED3_PIN as gpio_t);
}
4 | 5 | 6 | 7 | _ => {}
};
}
pub const LED3_PIN: libc::c_int = (0 as libc::c_int) << 5 as libc::c_int
| 12 as libc::c_int;
pub const LED2_PIN: libc::c_int = (1 as libc::c_int) << 5 as libc::c_int
| 9 as libc::c_int;
pub const LED1_PIN: libc::c_int = (0 as libc::c_int) << 5 as libc::c_int
| 8 as libc::c_int;
pub const LED0_PIN: libc::c_int = (0 as libc::c_int) << 5 as libc::c_int
| 6 as libc::c_int;
#[inline]
pub unsafe fn led_off(mut id: libc::c_uint) {
match id {
0 => {
gpio_set(LED0_PIN as gpio_t);
}
1 => {
gpio_set(LED1_PIN as gpio_t);
}
2 => {
gpio_set(LED2_PIN as gpio_t);
}
3 => {
gpio_set(LED3_PIN as gpio_t);
}
4 | 5 | 6 | 7 | _ => {}
};
}
#[inline]
pub unsafe fn led_toggle(mut id: libc::c_uint) {
match id {
0 => {
gpio_toggle(LED0_PIN as gpio_t);
}
1 => {
gpio_toggle(LED1_PIN as gpio_t);
}
2 => {
gpio_toggle(LED2_PIN as gpio_t);
}
3 => {
gpio_toggle(LED3_PIN as gpio_t);
}
4 | 5 | 6 | 7 | _ => {}
};
}
pub const SOCK_ADDR_ANY_NETIF: libc::c_int = 0 as libc::c_int;
pub const AF_INET_0: libc::c_int = AF_INET as libc::c_int;
#[inline]
pub unsafe fn coap_method2flag(mut code: libc::c_uint) -> coap_method_flags_t {
return ((1 as libc::c_int) << code.wrapping_sub(1 as libc::c_int as libc::c_uint))
as coap_method_flags_t;
}
#[inline]
pub unsafe fn coap_payload_advance_bytes(
mut pkt: *mut coap_pkt_t,
mut len: size_t,
) {
(*pkt).payload = ((*pkt).payload).offset(len as isize);
(*pkt)
.payload_len = ((*pkt).payload_len as libc::c_uint).wrapping_sub(len) as uint16_t
as uint16_t;
}
#[inline]
pub unsafe fn coap_has_observe(mut pkt: *mut coap_pkt_t) -> bool {
return (*pkt).observe_value != UINT32_MAX;
}
#[inline]
pub unsafe fn coap_clear_observe(mut pkt: *mut coap_pkt_t) {
(*pkt).observe_value = UINT32_MAX;
}
#[inline]
pub unsafe fn coap_get_observe(mut pkt: *mut coap_pkt_t) -> uint32_t {
return (*pkt).observe_value;
}
#[no_mangle]
pub const unsafe fn macro_SOCK_IPV4_EP_ANY() -> sock_udp_ep_t {
let mut result: sock_udp_ep_t = {
let mut init = _sock_tl_ep {
family: AF_INET_0,
addr: C2RustUnnamed_4 { ipv6: [0; 16] },
netif: SOCK_ADDR_ANY_NETIF as uint16_t,
port: 0,
};
init
};
return result;
}
#[no_mangle]
pub const unsafe fn macro_SOCK_IPV6_EP_ANY() -> sock_udp_ep_t {
let mut result: sock_udp_ep_t = {
let mut init = _sock_tl_ep {
family: AF_INET6_0,
addr: C2RustUnnamed_4 { ipv6: [0; 16] },
netif: SOCK_ADDR_ANY_NETIF as uint16_t,
port: 0,
};
init
};
return result;
}
#[no_mangle]
pub const unsafe fn macro_MUTEX_INIT() -> mutex_t {
let mut result: mutex_t = {
let mut init = mutex_t {
queue: {
let mut init = list_node {
next: NULL_2 as *mut list_node,
};
init
},
};
init
};
return result;
}
#[no_mangle]
pub const unsafe fn macro_STATUS_NOT_FOUND() -> thread_status_t {
let mut result: thread_status_t = STATUS_NOT_FOUND as thread_status_t;
return result;
}
#[no_mangle]
pub unsafe fn macro_GPIO_PIN(
mut port: libc::c_uint,
mut pin: libc::c_uint,
) -> gpio_t {
let mut result: gpio_t = (port << 5 as libc::c_int | pin) as gpio_t;
return result;
}
#[no_mangle]
pub unsafe fn macro_I2C_DEV(mut num: libc::c_uint) -> i2c_t {
let mut result: i2c_t = num as i2c_t;
return result;
}
#[no_mangle]
pub unsafe fn macro_SPI_DEV(mut num: libc::c_uint) -> spi_t {
let mut result: spi_t = num as spi_t;
return result;
}
pub const __INT16_MAX__: libc::c_int = 32767 as libc::c_int;
#[no_mangle]
pub unsafe fn macro_UART_DEV(mut num: libc::c_uint) -> uart_t {
let mut result: uart_t = num as uart_t;
return result;
}
#[no_mangle]
pub unsafe fn macro_PWM_DEV(mut num: libc::c_uint) -> pwm_t {
let mut result: pwm_t = num as pwm_t;
return result;
}
#[no_mangle]
pub unsafe fn macro_ADC_LINE(mut num: libc::c_uint) -> adc_t {
let mut result: adc_t = num as adc_t;
return result;
}
#[no_mangle]
pub unsafe fn macro_TIMER_DEV(mut num: libc::c_uint) -> timer_t {
let mut result: timer_t = num as timer_t;
return result;
}
#[no_mangle]
pub unsafe fn macro_LED0_ON() {
gpio_clear(LED0_PIN as gpio_t);
}
#[no_mangle]
pub unsafe fn macro_LED0_OFF() {
gpio_set(LED0_PIN as gpio_t);
}
#[no_mangle]
pub unsafe fn macro_LED0_TOGGLE() {
gpio_toggle(LED0_PIN as gpio_t);
}
#[no_mangle]
pub const unsafe fn macro_LED0_IS_PRESENT() -> libc::c_int {
let mut result: libc::c_int = 0;
return result;
}
#[no_mangle]
pub unsafe fn macro_LED1_ON() {
gpio_clear(LED1_PIN as gpio_t);
}
#[no_mangle]
pub unsafe fn macro_LED1_OFF() {
gpio_set(LED1_PIN as gpio_t);
}
#[no_mangle]
pub unsafe fn macro_LED1_TOGGLE() {
gpio_toggle(LED1_PIN as gpio_t);
}
#[no_mangle]
pub const unsafe fn macro_LED1_IS_PRESENT() -> libc::c_int {
let mut result: libc::c_int = 0;
return result;
}
#[no_mangle]
pub unsafe fn macro_LED2_ON() {
gpio_clear(LED2_PIN as gpio_t);
}
#[no_mangle]
pub unsafe fn macro_LED2_OFF() {
gpio_set(LED2_PIN as gpio_t);
}
#[no_mangle]
pub unsafe fn macro_LED2_TOGGLE() {
gpio_toggle(LED2_PIN as gpio_t);
}
#[no_mangle]
pub const unsafe fn macro_LED2_IS_PRESENT() -> libc::c_int {
let mut result: libc::c_int = 0;
return result;
}
#[no_mangle]
pub unsafe fn macro_LED3_ON() {
gpio_clear(LED3_PIN as gpio_t);
}
#[no_mangle]
pub unsafe fn macro_LED3_OFF() {
gpio_set(LED3_PIN as gpio_t);
}
#[no_mangle]
pub unsafe fn macro_LED3_TOGGLE() {
gpio_toggle(LED3_PIN as gpio_t);
}
#[no_mangle]
pub const unsafe fn macro_LED3_IS_PRESENT() -> libc::c_int {
let mut result: libc::c_int = 0;
return result;
}
#[no_mangle]
pub unsafe fn macro_LED4_ON() {}
#[no_mangle]
pub unsafe fn macro_LED4_OFF() {}
#[no_mangle]
pub unsafe fn macro_LED4_TOGGLE() {}
#[no_mangle]
pub const unsafe fn macro_LED4_IS_PRESENT() -> libc::c_int {
return -(1 as libc::c_int);
}
#[no_mangle]
pub unsafe fn macro_LED5_ON() {}
#[no_mangle]
pub unsafe fn macro_LED5_OFF() {}
#[no_mangle]
pub unsafe fn macro_LED5_TOGGLE() {}
#[no_mangle]
pub const unsafe fn macro_LED5_IS_PRESENT() -> libc::c_int {
return -(1 as libc::c_int);
}
#[no_mangle]
pub unsafe fn macro_LED6_ON() {}
#[no_mangle]
pub unsafe fn macro_LED6_OFF() {}
#[no_mangle]
pub unsafe fn macro_LED6_TOGGLE() {}
#[no_mangle]
pub const unsafe fn macro_LED6_IS_PRESENT() -> libc::c_int {
return -(1 as libc::c_int);
}
#[no_mangle]
pub unsafe fn macro_LED7_ON() {}
#[no_mangle]
pub unsafe fn macro_LED7_OFF() {}
#[no_mangle]
pub unsafe fn macro_LED7_TOGGLE() {}
#[no_mangle]
pub const unsafe fn macro_LED7_IS_PRESENT() -> libc::c_int {
return -(1 as libc::c_int);
}