Browse Source

Use uintptr_t for pointer-to-int

Scott Lahteine 5 years ago
parent
commit
b3ca43fe78

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

156
     // Start and end the dump on a nice 16 byte boundary
156
     // Start and end the dump on a nice 16 byte boundary
157
     // (even though the values are not 16-byte aligned).
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
     // Dump command main loop
162
     // Dump command main loop
163
     while (start_free_memory < end_free_memory) {
163
     while (start_free_memory < end_free_memory) {
189
     // Round the start and end locations to produce full lines of output
189
     // Round the start and end locations to produce full lines of output
190
     //
190
     //
191
     dump_free_memory(
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
  *
20
  *
21
  */
21
  */
22
 
22
 
23
-#include "../inc/MarlinConfig.h"
24
-#include "../gcode/parser.h"
23
+#include "../inc/MarlinConfigPre.h"
25
 
24
 
26
 #if NEED_HEX_PRINT
25
 #if NEED_HEX_PRINT
27
 
26
 
28
 #include "hex_print.h"
27
 #include "hex_print.h"
28
+#include "../core/serial.h"
29
 
29
 
30
 #ifdef CPU_32_BIT
30
 #ifdef CPU_32_BIT
31
   constexpr int byte_start = 4;
31
   constexpr int byte_start = 4;
54
 }
54
 }
55
 
55
 
56
 #ifdef CPU_32_BIT
56
 #ifdef CPU_32_BIT
57
-  char* hex_long(const uint32_t l) {
57
+  char* hex_long(const uintptr_t l) {
58
     _hex[2] = hex_nybble(l >> 28);
58
     _hex[2] = hex_nybble(l >> 28);
59
     _hex[3] = hex_nybble(l >> 24);
59
     _hex[3] = hex_nybble(l >> 24);
60
     _hex[4] = hex_nybble(l >> 20);
60
     _hex[4] = hex_nybble(l >> 20);
66
 
66
 
67
 char* hex_address(const void * const w) {
67
 char* hex_address(const void * const w) {
68
   #ifdef CPU_32_BIT
68
   #ifdef CPU_32_BIT
69
-    (void)hex_long((ptr_int_t)w);
69
+    (void)hex_long((uintptr_t)w);
70
   #else
70
   #else
71
-    (void)hex_word((ptr_int_t)w);
71
+    (void)hex_word((uintptr_t)w);
72
   #endif
72
   #endif
73
   return _hex;
73
   return _hex;
74
 }
74
 }
78
 void print_hex_word(const uint16_t w)        { SERIAL_ECHO(hex_word(w));    }
78
 void print_hex_word(const uint16_t w)        { SERIAL_ECHO(hex_word(w));    }
79
 void print_hex_address(const void * const w) { SERIAL_ECHO(hex_address(w)); }
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
   SERIAL_ECHOPGM("0x");
82
   SERIAL_ECHOPGM("0x");
83
   for (int B = 24; B >= 8; B -= 8){
83
   for (int B = 24; B >= 8; B -= 8){
84
     print_hex_byte(w >> B);
84
     print_hex_byte(w >> B);

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

39
 void print_hex_word(const uint16_t w);
39
 void print_hex_word(const uint16_t w);
40
 void print_hex_address(const void * const w);
40
 void print_hex_address(const void * const w);
41
 void print_hex_long(const uint32_t w, const char delimiter);
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