comparison gdb_remote.c @ 1949:5a76a7373823

Get WIP net play code compiling on Windows and cleanup some unistd.h includes
author Michael Pavone <pavone@retrodev.com>
date Thu, 30 Apr 2020 23:15:50 -0700
parents ba7231d2411c
children 495569c1dc61
comparison
equal deleted inserted replaced
1948:d01527615c7c 1949:5a76a7373823
16 #else 16 #else
17 #define GDB_IN_FD STDIN_FILENO 17 #define GDB_IN_FD STDIN_FILENO
18 #define GDB_OUT_FD STDOUT_FILENO 18 #define GDB_OUT_FD STDOUT_FILENO
19 #define GDB_READ read 19 #define GDB_READ read
20 #define GDB_WRITE write 20 #define GDB_WRITE write
21 #include <unistd.h>
21 #endif 22 #endif
22 23
23 #include "gdb_remote.h" 24 #include "gdb_remote.h"
24 #include "68kinst.h" 25 #include "68kinst.h"
25 #include "debug.h" 26 #include "debug.h"
26 #include "util.h" 27 #include "util.h"
27 #include <unistd.h>
28 #include <fcntl.h> 28 #include <fcntl.h>
29 #include <stddef.h> 29 #include <stddef.h>
30 #include <stdlib.h> 30 #include <stdlib.h>
31 #include <stdio.h> 31 #include <stdio.h>
32 #include <string.h> 32 #include <string.h>
556 curbuf = NULL; 556 curbuf = NULL;
557 } 557 }
558 } 558 }
559 } 559 }
560 560
561 #ifdef _WIN32
562 void gdb_cleanup(void)
563 {
564 WSACleanup();
565 }
566 WSADATA wsa_data;
567 #endif
568
569 void gdb_remote_init(void) 561 void gdb_remote_init(void)
570 { 562 {
571 buf = malloc(INITIAL_BUFFER_SIZE); 563 buf = malloc(INITIAL_BUFFER_SIZE);
572 curbuf = NULL; 564 curbuf = NULL;
573 bufsize = INITIAL_BUFFER_SIZE; 565 bufsize = INITIAL_BUFFER_SIZE;
574 #ifdef _WIN32 566 #ifdef _WIN32
575 WSAStartup(MAKEWORD(2,2), &wsa_data); 567 socket_init();
576 568
577 struct addrinfo request, *result; 569 struct addrinfo request, *result;
578 memset(&request, 0, sizeof(request)); 570 memset(&request, 0, sizeof(request));
579 request.ai_family = AF_INET; 571 request.ai_family = AF_INET;
580 request.ai_socktype = SOCK_STREAM; 572 request.ai_socktype = SOCK_STREAM;
594 } 586 }
595 gdb_sock = accept(listen_sock, NULL, NULL); 587 gdb_sock = accept(listen_sock, NULL, NULL);
596 if (gdb_sock < 0) { 588 if (gdb_sock < 0) {
597 fatal_error("accept returned an error while listening on GDB remote debugging socket"); 589 fatal_error("accept returned an error while listening on GDB remote debugging socket");
598 } 590 }
599 closesocket(listen_sock); 591 socket_close(listen_sock);
600 #else 592 #else
601 disable_stdout_messages(); 593 disable_stdout_messages();
602 #endif 594 #endif
603 } 595 }