Browse Source

Use uintptr_t for pointer-to-int

vanilla_fb_2.0.x
Scott Lahteine 4 years ago
parent
commit
b3ca43fe78
  1. 8
      Marlin/src/gcode/calibrate/M100.cpp
  2. 12
      Marlin/src/libs/hex_print.cpp
  3. 6
      Marlin/src/libs/hex_print.h

8
Marlin/src/gcode/calibrate/M100.cpp

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

12
Marlin/src/libs/hex_print.cpp

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

6
Marlin/src/libs/hex_print.h

@ -39,9 +39,3 @@ void print_hex_byte(const uint8_t b);
void print_hex_word(const uint16_t w); void print_hex_word(const uint16_t w);
void print_hex_address(const void * const w); void print_hex_address(const void * const w);
void print_hex_long(const uint32_t w, const char delimiter); 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

Loading…
Cancel
Save