(flags: *mut c_void, array: *mut PyArrayObject)
| 57 | } |
| 58 | |
| 59 | unsafe extern "C" fn acquire_mut_shared(flags: *mut c_void, array: *mut PyArrayObject) -> c_int { |
| 60 | if (*array).flags & NPY_ARRAY_WRITEABLE == 0 { |
| 61 | return -2; |
| 62 | } |
| 63 | |
| 64 | // SAFETY: must be attached when calling `acquire_shared`. |
| 65 | let py = Python::assume_attached(); |
| 66 | let flags = &*(flags as *mut BorrowFlags); |
| 67 | |
| 68 | let address = base_address(py, array); |
| 69 | let key = borrow_key(py, array); |
| 70 | |
| 71 | match flags.acquire_mut(address, key) { |
| 72 | Ok(()) => 0, |
| 73 | Err(()) => -1, |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | unsafe extern "C" fn release_shared(flags: *mut c_void, array: *mut PyArrayObject) { |
| 78 | // SAFETY: must be attached when calling `acquire_shared`. |
nothing calls this directly
no test coverage detected