summaryrefslogtreecommitdiff
path: root/src/st-util/gdb-remote.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/st-util/gdb-remote.c')
-rw-r--r--src/st-util/gdb-remote.c42
1 files changed, 21 insertions, 21 deletions
diff --git a/src/st-util/gdb-remote.c b/src/st-util/gdb-remote.c
index bdf8afd..25ca4da 100644
--- a/src/st-util/gdb-remote.c
+++ b/src/st-util/gdb-remote.c
@@ -5,8 +5,8 @@
#include <stdio.h>
#include <string.h>
-#include <stdlib.h>
#include <stdint.h>
+#include <stdlib.h>
#if defined(_WIN32)
#include <win32_socket.h>
@@ -19,9 +19,9 @@
static const char hex[] = "0123456789abcdef";
-int gdb_send_packet(int fd, char* data) {
- unsigned int data_length = (unsigned int)strlen(data);
- int length = data_length + 4;
+int32_t gdb_send_packet(int32_t fd, char* data) {
+ uint32_t data_length = (uint32_t)strlen(data);
+ int32_t length = data_length + 4;
char* packet = malloc(length); // '$' data (hex) '#' cksum (hex)
memset(packet, 0, length);
@@ -30,7 +30,7 @@ int gdb_send_packet(int fd, char* data) {
uint8_t cksum = 0;
- for (unsigned int i = 0; i < data_length; i++) {
+ for (uint32_t i = 0; i < data_length; i++) {
packet[i + 1] = data[i];
cksum += data[i];
}
@@ -42,34 +42,34 @@ int gdb_send_packet(int fd, char* data) {
while (1) {
if (write(fd, packet, length) != length) {
free(packet);
- return(-2);
+ return (-2);
}
char ack;
if (read(fd, &ack, 1) != 1) {
free(packet);
- return(-2);
+ return (-2);
}
if (ack == '+') {
free(packet);
- return(0);
+ return (0);
}
}
}
#define ALLOC_STEP 1024
-int gdb_recv_packet(int fd, char** buffer) {
- unsigned packet_size = ALLOC_STEP + 1, packet_idx = 0;
+int32_t gdb_recv_packet(int32_t fd, char** buffer) {
+ uint32_t packet_size = ALLOC_STEP + 1, packet_idx = 0;
uint8_t cksum = 0;
char recv_cksum[3] = {0};
char* packet_buffer = malloc(packet_size);
- unsigned state;
+ uint32_t state;
if (packet_buffer == NULL) {
- return(-2);
+ return (-2);
}
start:
@@ -88,7 +88,7 @@ start:
while (state != 4) {
if (read(fd, &c, 1) != 1) {
free(packet_buffer);
- return(-2);
+ return (-2);
}
switch (state) {
@@ -117,7 +117,7 @@ start:
packet_buffer = p;
} else {
free(packet_buffer);
- return(-2);
+ return (-2);
}
}
}
@@ -143,7 +143,7 @@ start:
if (write(fd, &nack, 1) != 1) {
free(packet_buffer);
- return(-2);
+ return (-2);
}
goto start;
@@ -152,14 +152,14 @@ start:
if (write(fd, &ack, 1) != 1) {
free(packet_buffer);
- return(-2);
+ return (-2);
}
}
packet_buffer[packet_idx] = 0;
*buffer = packet_buffer;
- return(packet_idx);
+ return (packet_idx);
}
/*
@@ -167,7 +167,7 @@ start:
* As we use the mode with ACK, in a (very unlikely) situation of a packet lost
* because of this skipping, it will be resent anyway.
*/
-int gdb_check_for_interrupt(int fd) {
+int32_t gdb_check_for_interrupt(int32_t fd) {
struct pollfd pfd;
pfd.fd = fd;
pfd.events = POLLIN;
@@ -176,13 +176,13 @@ int gdb_check_for_interrupt(int fd) {
char c;
if (read(fd, &c, 1) != 1) {
- return(-2);
+ return (-2);
}
if (c == '\x03') {
- return(1); // ^C
+ return (1); // ^C
}
}
- return(0);
+ return (0);
}