Skip to content

Commit 61cb0c3

Browse files
committed
PR Feedback
1 parent 9604994 commit 61cb0c3

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

tools/swift-inspect/Sources/AndroidCLib/heap.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,18 +57,18 @@
5757
// a different process for execution, it must not make any function calls. It
5858
// could be written as asm, but simple C is more readable/maintainable and
5959
// should consistently compile to movable, position-independent code.
60-
void heap_iterate_callback(unsigned long base, unsigned long size, void *arg) {
60+
static void heap_iterate_callback(unsigned long base, unsigned long size, void *arg) {
6161
volatile uint64_t *data = (uint64_t*)arg;
6262
while (data[NEXT_FREE_IDX] >= data[MAX_VALID_IDX]) {
6363
// SIGTRAP indicates the buffer is full and needs to be drained before more
6464
// entries can be written.
6565
__builtin_debugtrap();
66-
asm volatile("nop");
66+
__asm__ __volatile__("nop");
6767
}
6868
data[data[NEXT_FREE_IDX]++] = base;
6969
data[data[NEXT_FREE_IDX]++] = size;
70-
asm volatile(".global heap_iterate_callback_end");
71-
asm volatile("heap_iterate_callback_end:");
70+
__asm__ __volatile(".local heap_iterate_callback_end");
71+
__asm__ __volatile__("heap_iterate_callback_end:");
7272
}
7373

7474
void* heap_iterate_callback_start() {
@@ -97,12 +97,12 @@ bool heap_iterate_metadata_process(
9797
void* data, size_t len, void* callback_context, heap_iterate_entry_callback_t callback) {
9898
uint64_t *metadata = data;
9999
const uint64_t max_entries = len / sizeof(uint64_t);
100+
const uint64_t end_index = metadata[NEXT_FREE_IDX];
100101

101-
if (metadata[MAX_VALID_IDX] != max_entries ||
102-
metadata[NEXT_FREE_IDX] > max_entries)
102+
if (metadata[MAX_VALID_IDX] != max_entries || end_index > max_entries)
103103
return false;
104104

105-
for (size_t i = HEADER_SIZE; i < metadata[NEXT_FREE_IDX]; i += ENTRY_SIZE) {
105+
for (size_t i = HEADER_SIZE; i < end_index; i += ENTRY_SIZE) {
106106
const uint64_t base = metadata[i];
107107
const uint64_t size = metadata[i + 1];
108108
callback(callback_context, base, size);

tools/swift-inspect/Sources/swift-inspect/String+Extensions.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,15 @@ extension DefaultStringInterpolation {
2222

2323
enum Std {
2424
struct File: TextOutputStream {
25+
2526
#if os(Android)
26-
var underlying: OpaquePointer
27+
typealias File = OpaquePointer
2728
#else
28-
var underlying: UnsafeMutablePointer<FILE>
29+
typealias File = UnsafeMutablePointer<FILE>
2930
#endif
3031

32+
var underlying: File
33+
3134
mutating func write(_ string: String) {
3235
fputs(string, underlying)
3336
}
@@ -38,4 +41,4 @@ enum Std {
3841

3942
internal func disableStdErrBuffer() {
4043
setvbuf(stderr, nil, Int32(_IONBF), 0)
41-
}
44+
}

0 commit comments

Comments
 (0)