(fd: i32, value: u64, width: usize)
| 148 | // _Py_DumpHexadecimal (traceback.c) |
| 149 | #[cfg(any(unix, windows))] |
| 150 | fn dump_hexadecimal(fd: i32, value: u64, width: usize) { |
| 151 | const HEX_CHARS: &[u8; 16] = b"0123456789abcdef"; |
| 152 | let mut buf = [0u8; 18]; // "0x" + 16 hex digits |
| 153 | buf[0] = b'0'; |
| 154 | buf[1] = b'x'; |
| 155 | |
| 156 | for i in 0..width { |
| 157 | let digit = ((value >> (4 * (width - 1 - i))) & 0xf) as usize; |
| 158 | buf[2 + i] = HEX_CHARS[digit]; |
| 159 | } |
| 160 | |
| 161 | let _ = unsafe { |
| 162 | #[cfg(windows)] |
| 163 | { |
| 164 | libc::write(fd, buf.as_ptr() as *const libc::c_void, (2 + width) as u32) |
| 165 | } |
| 166 | #[cfg(not(windows))] |
| 167 | { |
| 168 | libc::write(fd, buf.as_ptr() as *const libc::c_void, 2 + width) |
| 169 | } |
| 170 | }; |
| 171 | } |
| 172 | |
| 173 | // _Py_DumpDecimal (traceback.c) |
| 174 | #[cfg(any(unix, windows))] |
no test coverage detected