Use uintptr_t for pointer-to-int

This commit is contained in:
Scott Lahteine 2020-08-07 19:30:35 -05:00 committed by Scott Lahteine
parent 7a8e99de7d
commit 8af8ef4404
3 changed files with 10 additions and 16 deletions

View File

@ -156,8 +156,8 @@ inline int32_t count_test_bytes(const char * const start_free_memory) {
// Start and end the dump on a nice 16 byte boundary
// (even though the values are not 16-byte aligned).
//
start_free_memory = (char*)(ptr_int_t(uint32_t(start_free_memory) & ~0xFUL)); // Align to 16-byte boundary
end_free_memory = (char*)(ptr_int_t(uint32_t(end_free_memory) | 0xFUL)); // Align end_free_memory to the 15th byte (at or above end_free_memory)
start_free_memory = (char*)(uintptr_t(uint32_t(start_free_memory) & ~0xFUL)); // Align to 16-byte boundary
end_free_memory = (char*)(uintptr_t(uint32_t(end_free_memory) | 0xFUL)); // Align end_free_memory to the 15th byte (at or above end_free_memory)
// Dump command main loop
while (start_free_memory < end_free_memory) {
@ -189,8 +189,8 @@ inline int32_t count_test_bytes(const char * const start_free_memory) {
// Round the start and end locations to produce full lines of output
//
dump_free_memory(
(char*)(ptr_int_t(uint32_t(start) & ~0xFUL)), // Align to 16-byte boundary
(char*)(ptr_int_t(uint32_t(end) | 0xFUL)) // Align end_free_memory to the 15th byte (at or above end_free_memory)
(char*)(uintptr_t(uint32_t(start) & ~0xFUL)), // Align to 16-byte boundary
(char*)(uintptr_t(uint32_t(end) | 0xFUL)) // Align end_free_memory to the 15th byte (at or above end_free_memory)
);
}

View File

@ -20,12 +20,12 @@
*
*/
#include "../inc/MarlinConfig.h"
#include "../gcode/parser.h"
#include "../inc/MarlinConfigPre.h"
#if NEED_HEX_PRINT
#include "hex_print.h"
#include "../core/serial.h"
#ifdef CPU_32_BIT
constexpr int byte_start = 4;
@ -54,7 +54,7 @@ char* hex_word(const uint16_t w) {
}
#ifdef CPU_32_BIT
char* hex_long(const uint32_t l) {
char* hex_long(const uintptr_t l) {
_hex[2] = hex_nybble(l >> 28);
_hex[3] = hex_nybble(l >> 24);
_hex[4] = hex_nybble(l >> 20);
@ -66,9 +66,9 @@ char* hex_word(const uint16_t w) {
char* hex_address(const void * const w) {
#ifdef CPU_32_BIT
(void)hex_long((ptr_int_t)w);
(void)hex_long((uintptr_t)w);
#else
(void)hex_word((ptr_int_t)w);
(void)hex_word((uintptr_t)w);
#endif
return _hex;
}
@ -78,7 +78,7 @@ void print_hex_byte(const uint8_t b) { SERIAL_ECHO(hex_byte(b)); }
void print_hex_word(const uint16_t w) { SERIAL_ECHO(hex_word(w)); }
void print_hex_address(const void * const w) { SERIAL_ECHO(hex_address(w)); }
void print_hex_long(const uint32_t w, const char delimiter) {
void print_hex_long(const uintptr_t w, const char delimiter) {
SERIAL_ECHOPGM("0x");
for (int B = 24; B >= 8; B -= 8){
print_hex_byte(w >> B);

View File

@ -39,9 +39,3 @@ void print_hex_byte(const uint8_t b);
void print_hex_word(const uint16_t w);
void print_hex_address(const void * const w);
void print_hex_long(const uint32_t w, const char delimiter);
#ifdef CPU_32_BIT
typedef uint32_t ptr_int_t;
#else
typedef uint16_t ptr_int_t;
#endif