Browse Source

Use uintptr_t for pointer-to-int

Scott Lahteine 3 years ago
parent
commit
b3ca43fe78
3 changed files with 10 additions and 16 deletions
  1. 4
    4
      Marlin/src/gcode/calibrate/M100.cpp
  2. 6
    6
      Marlin/src/libs/hex_print.cpp
  3. 0
    6
      Marlin/src/libs/hex_print.h

+ 4
- 4
Marlin/src/gcode/calibrate/M100.cpp View File

@@ -156,8 +156,8 @@ inline int32_t count_test_bytes(const char * const start_free_memory) {
156 156
     // Start and end the dump on a nice 16 byte boundary
157 157
     // (even though the values are not 16-byte aligned).
158 158
     //
159
-    start_free_memory = (char*)(ptr_int_t(uint32_t(start_free_memory) & ~0xFUL)); // Align to 16-byte boundary
160
-    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)
159
+    start_free_memory = (char*)(uintptr_t(uint32_t(start_free_memory) & ~0xFUL)); // Align to 16-byte boundary
160
+    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)
161 161
 
162 162
     // Dump command main loop
163 163
     while (start_free_memory < end_free_memory) {
@@ -189,8 +189,8 @@ inline int32_t count_test_bytes(const char * const start_free_memory) {
189 189
     // Round the start and end locations to produce full lines of output
190 190
     //
191 191
     dump_free_memory(
192
-      (char*)(ptr_int_t(uint32_t(start) & ~0xFUL)), // Align to 16-byte boundary
193
-      (char*)(ptr_int_t(uint32_t(end)   |  0xFUL))  // Align end_free_memory to the 15th byte (at or above end_free_memory)
192
+      (char*)(uintptr_t(uint32_t(start) & ~0xFUL)), // Align to 16-byte boundary
193
+      (char*)(uintptr_t(uint32_t(end)   |  0xFUL))  // Align end_free_memory to the 15th byte (at or above end_free_memory)
194 194
     );
195 195
   }
196 196
 

+ 6
- 6
Marlin/src/libs/hex_print.cpp View File

@@ -20,12 +20,12 @@
20 20
  *
21 21
  */
22 22
 
23
-#include "../inc/MarlinConfig.h"
24
-#include "../gcode/parser.h"
23
+#include "../inc/MarlinConfigPre.h"
25 24
 
26 25
 #if NEED_HEX_PRINT
27 26
 
28 27
 #include "hex_print.h"
28
+#include "../core/serial.h"
29 29
 
30 30
 #ifdef CPU_32_BIT
31 31
   constexpr int byte_start = 4;
@@ -54,7 +54,7 @@ char* hex_word(const uint16_t w) {
54 54
 }
55 55
 
56 56
 #ifdef CPU_32_BIT
57
-  char* hex_long(const uint32_t l) {
57
+  char* hex_long(const uintptr_t l) {
58 58
     _hex[2] = hex_nybble(l >> 28);
59 59
     _hex[3] = hex_nybble(l >> 24);
60 60
     _hex[4] = hex_nybble(l >> 20);
@@ -66,9 +66,9 @@ char* hex_word(const uint16_t w) {
66 66
 
67 67
 char* hex_address(const void * const w) {
68 68
   #ifdef CPU_32_BIT
69
-    (void)hex_long((ptr_int_t)w);
69
+    (void)hex_long((uintptr_t)w);
70 70
   #else
71
-    (void)hex_word((ptr_int_t)w);
71
+    (void)hex_word((uintptr_t)w);
72 72
   #endif
73 73
   return _hex;
74 74
 }
@@ -78,7 +78,7 @@ void print_hex_byte(const uint8_t b)         { SERIAL_ECHO(hex_byte(b));    }
78 78
 void print_hex_word(const uint16_t w)        { SERIAL_ECHO(hex_word(w));    }
79 79
 void print_hex_address(const void * const w) { SERIAL_ECHO(hex_address(w)); }
80 80
 
81
-void print_hex_long(const uint32_t w, const char delimiter) {
81
+void print_hex_long(const uintptr_t w, const char delimiter) {
82 82
   SERIAL_ECHOPGM("0x");
83 83
   for (int B = 24; B >= 8; B -= 8){
84 84
     print_hex_byte(w >> B);

+ 0
- 6
Marlin/src/libs/hex_print.h View File

@@ -39,9 +39,3 @@ void print_hex_byte(const uint8_t b);
39 39
 void print_hex_word(const uint16_t w);
40 40
 void print_hex_address(const void * const w);
41 41
 void print_hex_long(const uint32_t w, const char delimiter);
42
-
43
-#ifdef CPU_32_BIT
44
-  typedef uint32_t ptr_int_t;
45
-#else
46
-  typedef uint16_t ptr_int_t;
47
-#endif

Loading…
Cancel
Save