Skip to content
Browse files

use WSAStartup on windows, replace bzero with memset

  • Loading branch information...
1 parent 6db2766 commit 2559ab0c30b6782e67c9a0a1622c04bde9ee51f5 @WinterMute WinterMute committed Apr 29, 2012
Showing with 13 additions and 1 deletion.
  1. +13 −1 gdbserver/gdb-server.c
View
14 gdbserver/gdb-server.c
@@ -170,8 +170,20 @@ int main(int argc, char** argv) {
current_memory_map = make_memory_map(sl);
+#ifdef __MINGW32__
+ WSADATA wsadata;
+ if (WSAStartup(MAKEWORD(2,2),&wsadata) !=0 ) {
+ goto winsock_error;
+ }
+#endif
+
while(serve(sl, state.listen_port) == 0);
+#ifdef __MINGW32__
+winsock_error:
+ WSACleanup();
+#endif
+
/* Switch back to mass storage mode before closing. */
stlink_run(sl);
stlink_exit_debug_mode(sl);
@@ -558,7 +570,7 @@ int serve(stlink_t *sl, int port) {
setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val));
struct sockaddr_in serv_addr;
- bzero(&serv_addr,sizeof(struct sockaddr_in));
+ memset(&serv_addr,0,sizeof(struct sockaddr_in));
serv_addr.sin_family = AF_INET;
serv_addr.sin_addr.s_addr = inet_addr("127.0.0.1");
serv_addr.sin_port = htons(port);

0 comments on commit 2559ab0

Please sign in to comment.
Something went wrong with that request. Please try again.