-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Stop the sulk with GPL2016 on Windows (#602)
* Fixes for VS2017. * Added a getopt implementation. * Added a unistd.h. * Corrected closing of sockets for Windows versions. * Fixed gdbserver CMakeLists.txt to play nice with VS2017. * Fixed include of getopt.h and unistd.h for WIN32. * Added a unistd.h. * Corrected closing of sockets for Windows versions. * Fixed gdbserver CMakeLists.txt to play nice with VS2017. * Override /MD to /MT for MSVC to match libusb's builds. * MSVC settings should be if (MSVC). * Don't busy-wait for long periods in usleep(). * Dynamic link to MSVC libusb binaries. * Added Visual Studio section to compiling.md. * Added -D_CRT_NONSTDC_NO_WARNINGS to MSVC flags. * Prevented some more warnings under MSVC.
- Loading branch information
Showing
20 changed files
with
515 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
if(MSVC) | ||
message(STATUS "MSVC C Flags override to /MT") | ||
set(CMAKE_C_FLAGS_DEBUG_INIT "/D_DEBUG /MTd /Zi /Ob0 /Od /RTC1") | ||
set(CMAKE_C_FLAGS_MINSIZEREL_INIT "/MT /O1 /Ob1 /D NDEBUG") | ||
set(CMAKE_C_FLAGS_RELEASE_INIT "/MT /O2 /Ob2 /D NDEBUG") | ||
set(CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "/MT /Zi /O2 /Ob1 /D NDEBUG") | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,18 @@ | ||
add_executable(st-util gdb-remote.c | ||
gdb-remote.h | ||
gdb-server.c | ||
gdb-server.h | ||
semihosting.c | ||
semihosting.h) | ||
set(STUTIL_SOURCE | ||
gdb-remote.c | ||
gdb-remote.h | ||
gdb-server.c | ||
gdb-server.h | ||
semihosting.c | ||
semihosting.h) | ||
|
||
if (MSVC) | ||
# We need a getopt from somewhere... | ||
set(STUTIL_SOURCE "${STUTIL_SOURCE};../getopt/getopt.c") | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
xor-gate
Member
|
||
endif() | ||
|
||
add_executable(st-util ${STUTIL_SOURCE}) | ||
|
||
if (WIN32 OR APPLE) | ||
target_link_libraries(st-util ${STLINK_LIB_STATIC}) | ||
else() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,11 @@ | |
#include <string.h> | ||
#include <stdlib.h> | ||
#include <sys/types.h> | ||
#ifdef __MINGW32__ | ||
#if defined(_MSC_VER) | ||
#include <stdbool.h> | ||
#define __attribute__(x) | ||
#endif | ||
#if defined(__MINGW32__) || defined(_MSC_VER) | ||
#include <mingw.h> | ||
#else | ||
#include <unistd.h> | ||
|
@@ -239,7 +243,7 @@ int main(int argc, char** argv) { | |
sl->verbose=0; | ||
current_memory_map = make_memory_map(sl); | ||
|
||
#ifdef __MINGW32__ | ||
#if defined(__MINGW32__) || defined(_MSC_VER) | ||
This comment has been minimized.
Sorry, something went wrong.
rpavlik
|
||
WSADATA wsadata; | ||
if (WSAStartup(MAKEWORD(2,2),&wsadata) !=0 ) { | ||
goto winsock_error; | ||
|
@@ -260,7 +264,7 @@ int main(int argc, char** argv) { | |
stlink_run(sl); | ||
} while (state.persistent); | ||
|
||
#ifdef __MINGW32__ | ||
#if defined(__MINGW32__) || defined(_MSC_VER) | ||
winsock_error: | ||
WSACleanup(); | ||
#endif | ||
|
@@ -1061,7 +1065,11 @@ int serve(stlink_t *sl, st_state_t *st) { | |
return 1; | ||
} | ||
|
||
close(sock); | ||
#if defined(__MINGW32__) || defined(_MSC_VER) | ||
win32_close_socket(sock); | ||
#else | ||
close(sock); | ||
#endif | ||
|
||
stlink_force_debug(sl); | ||
if (st->reset) { | ||
|
@@ -1084,8 +1092,8 @@ int serve(stlink_t *sl, st_state_t *st) { | |
int status = gdb_recv_packet(client, &packet); | ||
if(status < 0) { | ||
ELOG("cannot recv: %d\n", status); | ||
#ifdef __MINGW32__ | ||
win32_close_socket(sock); | ||
#if defined(__MINGW32__) || defined(_MSC_VER) | ||
win32_close_socket(client); | ||
#endif | ||
return 1; | ||
} | ||
|
@@ -1337,8 +1345,8 @@ int serve(stlink_t *sl, st_state_t *st) { | |
status = gdb_check_for_interrupt(client); | ||
if(status < 0) { | ||
ELOG("cannot check for int: %d\n", status); | ||
#ifdef __MINGW32__ | ||
win32_close_socket(sock); | ||
#if defined(__MINGW32__) || defined(_MSC_VER) | ||
win32_close_socket(client); | ||
#endif | ||
return 1; | ||
} | ||
|
@@ -1739,8 +1747,8 @@ int serve(stlink_t *sl, st_state_t *st) { | |
ELOG("cannot send: %d\n", result); | ||
free(reply); | ||
free(packet); | ||
#ifdef __MINGW32__ | ||
win32_close_socket(sock); | ||
#if defined(__MINGW32__) || defined(_MSC_VER) | ||
win32_close_socket(client); | ||
#endif | ||
return 1; | ||
} | ||
|
@@ -1751,8 +1759,8 @@ int serve(stlink_t *sl, st_state_t *st) { | |
free(packet); | ||
} | ||
|
||
#ifdef __MINGW32__ | ||
win32_close_socket(sock); | ||
#if defined(__MINGW32__) || defined(_MSC_VER) | ||
win32_close_socket(client); | ||
#endif | ||
|
||
return 0; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
Copyright (c) 2012, Kim Gräsman | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
* Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
* Redistributions in binary form must reproduce the above copyright | ||
notice, this list of conditions and the following disclaimer in the | ||
documentation and/or other materials provided with the distribution. | ||
* Neither the name of Kim Gräsman nor the | ||
names of contributors may be used to endorse or promote products | ||
derived from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL KIM GRÄSMAN BE LIABLE FOR ANY | ||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
getopt_port | ||
=========== | ||
|
||
[Kim Gräsman](http://grundlig.wordpress.com) | ||
[@kimgr](http://twitter.com/kimgr) | ||
|
||
An original implementation of `getopt` and `getopt_long` with limited GNU extensions. Provided under the BSD license, to allow non-GPL projects to use `getopt`-style command-line parsing. | ||
|
||
So far only built with Visual C++, but has no inherently non-portable constructs. | ||
|
||
Intended to be embedded into your code tree -- `getopt.h` and `getopt.c` are self-contained and should work in any context. | ||
|
||
Comes with a reasonable unit test suite. | ||
|
||
See also: | ||
|
||
* [Full Win32 getopt port](http://www.codeproject.com/Articles/157001/Full-getopt-Port-for-Unicode-and-Multibyte-Microso) -- LGPL licensed. | ||
* [XGetOpt](http://www.codeproject.com/Articles/1940/XGetopt-A-Unix-compatible-getopt-for-MFC-and-Win32) -- No `getopt_long` support. | ||
* [Free Getopt](https://sourceforge.net/projects/freegetopt/) -- No `getopt_long` support. | ||
|
||
For license terms, see LICENSE.txt. |
Oops, something went wrong.
This can actually be
Marginally faster, as well as clearer.