Mercurial > crates > nonstick
comparison libpam-sys/src/helpers.rs @ 127:c77846f3a979
GET CTEST WORKING.
This will verify that the functions we're exporting are correct.
It has been a nightmare.
author | Paul Fisher <paul@pfish.zone> |
---|---|
date | Mon, 30 Jun 2025 22:56:26 -0400 |
parents | 2b255c92417b |
children |
comparison
equal
deleted
inserted
replaced
126:57c812e308bd | 127:c77846f3a979 |
---|---|
1 //! This module contains a few non-required helpers to deal with some of the | 1 //! This module contains a few non-required helpers to deal with some of the |
2 //! more annoying memory management in the PAM API. | 2 //! more annoying memory management in the PAM API. |
3 | 3 |
4 use super::cfg_pam_impl; | |
4 use std::error::Error; | 5 use std::error::Error; |
5 use std::marker::{PhantomData, PhantomPinned}; | 6 use std::marker::{PhantomData, PhantomPinned}; |
6 use std::mem::ManuallyDrop; | 7 use std::mem::ManuallyDrop; |
7 use std::ptr::NonNull; | 8 use std::ptr::NonNull; |
8 use std::{any, fmt, mem, slice}; | 9 use std::{any, fmt, mem, slice}; |
130 { | 131 { |
131 Self::assert_size::<Src>(); | 132 Self::assert_size::<Src>(); |
132 slice::from_raw_parts(*ptr_ptr.cast(), count).iter() | 133 slice::from_raw_parts(*ptr_ptr.cast(), count).iter() |
133 } | 134 } |
134 | 135 |
135 #[crate::cfg_pam_impl("LinuxPam")] | 136 #[cfg_pam_impl("LinuxPam")] |
136 unsafe fn _iter_over<'a, Src>( | 137 unsafe fn _iter_over<'a, Src>( |
137 ptr_ptr: *const *const Src, | 138 ptr_ptr: *const *const Src, |
138 count: usize, | 139 count: usize, |
139 ) -> impl Iterator<Item = &'a T> | 140 ) -> impl Iterator<Item = &'a T> |
140 where | 141 where |
142 { | 143 { |
143 #[allow(deprecated)] | 144 #[allow(deprecated)] |
144 Self::iter_over_linux(ptr_ptr, count) | 145 Self::iter_over_linux(ptr_ptr, count) |
145 } | 146 } |
146 | 147 |
147 #[crate::cfg_pam_impl(not("LinuxPam"))] | 148 #[cfg_pam_impl(not("LinuxPam"))] |
148 unsafe fn _iter_over<'a, Src>( | 149 unsafe fn _iter_over<'a, Src>( |
149 ptr_ptr: *const *const Src, | 150 ptr_ptr: *const *const Src, |
150 count: usize, | 151 count: usize, |
151 ) -> impl Iterator<Item = &'a T> | 152 ) -> impl Iterator<Item = &'a T> |
152 where | 153 where |
476 #[cfg(debug_assertions)] | 477 #[cfg(debug_assertions)] |
477 #[test] | 478 #[test] |
478 #[should_panic] | 479 #[should_panic] |
479 fn test_iter_xsso_wrong_size() { | 480 fn test_iter_xsso_wrong_size() { |
480 unsafe { | 481 unsafe { |
481 _ = PtrPtrVec::<u8>::iter_over_xsso::<f64>(ptr::null(), 1); | 482 let _ = PtrPtrVec::<u8>::iter_over_xsso::<f64>(ptr::null(), 1); |
482 } | 483 } |
483 } | 484 } |
484 | 485 |
485 #[allow(deprecated)] | 486 #[allow(deprecated)] |
486 #[cfg(debug_assertions)] | 487 #[cfg(debug_assertions)] |
487 #[test] | 488 #[test] |
488 #[should_panic] | 489 #[should_panic] |
489 fn test_iter_linux_wrong_size() { | 490 fn test_iter_linux_wrong_size() { |
490 unsafe { | 491 unsafe { |
491 _ = PtrPtrVec::<u128>::iter_over_linux::<()>(ptr::null(), 1); | 492 let _ = PtrPtrVec::<u128>::iter_over_linux::<()>(ptr::null(), 1); |
492 } | 493 } |
493 } | 494 } |
494 | 495 |
495 #[allow(deprecated)] | 496 #[allow(deprecated)] |
496 #[test] | 497 #[test] |