ring/c.rs
1// Copyright 2016-2019 Brian Smith.
2//
3// Permission to use, copy, modify, and/or distribute this software for any
4// purpose with or without fee is hereby granted, provided that the above
5// copyright notice and this permission notice appear in all copies.
6//
7// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
10// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
12// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
13// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14
15//! C types.
16//!
17//! Avoid using the `libc` crate to get C types since `libc` doesn't support
18//! all the targets we need to support. It turns out that the few types we need
19//! are all uniformly defined on the platforms we care about. This will
20//! probably change if/when we support 16-bit platforms or platforms where
21//! `usize` and `uintptr_t` are different sizes.
22//!
23//! TODO(MSRV, feature(c_size_t)): Use `core::{ffi::c_size_t}`.
24//! TODO(MSRV-1.79): Use `NonZero<c_size_t>`.
25
26// Keep in sync with the checks in base.h that verify these assumptions.
27
28#![allow(dead_code)]
29
30use core::num::NonZeroUsize;
31
32pub(crate) type size_t = usize;
33pub(crate) type NonZero_size_t = NonZeroUsize;