Merge ~sjr/kicad:msvc into ~kicad-product-committers/kicad:master

Proposed by Simon Richter
Status: Merged
Merge reported by: Wayne Stambaugh
Merged at revision: 2586a1c4b24f865f788a2a764b3f4403e2696407
Proposed branch: ~sjr/kicad:msvc
Merge into: ~kicad-product-committers/kicad:master
Diff against target: 663 lines (+144/-354)
10 files modified
CMakeLists.txt (+40/-0)
common/gal/cairo/cairo_print.cpp (+6/-0)
common/system/libcontext.cpp (+66/-0)
dev/null (+0/-342)
eeschema/sim/ngspice.cpp (+1/-0)
include/lib_tree_item.h (+2/-2)
include/system/libcontext.h (+15/-1)
include/tool/coroutine.h (+6/-2)
pcbnew/pcb_edit_frame.h (+2/-1)
pcbnew/pcbnew_config.cpp (+6/-6)
Reviewer Review Type Date Requested Status
Wayne Stambaugh Approve
Review via email: mp+369768@code.launchpad.net

Commit message

Microsoft Visual Studio compiler support

To post a comment you must log in.
Revision history for this message
Wayne Stambaugh (stambaughw) wrote :

I didn't actually test the MSVC build but it doesn't break the current msys2 builds in any way so I'm fine with merging this for those of you who want to use MSVC.

review: Approve
Revision history for this message
Wayne Stambaugh (stambaughw) wrote :

@Simon, I merge your changes into the master branch. Thanks.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/CMakeLists.txt b/CMakeLists.txt
2index ee43d9e..74c0c08 100644
3--- a/CMakeLists.txt
4+++ b/CMakeLists.txt
5@@ -108,6 +108,10 @@ option( KICAD_SPICE
6 "Build KiCad with internal Spice simulator."
7 ON )
8
9+option( KICAD_BUILD_PARALLEL_CL_MP
10+ "Build in parallel using the /MP compiler option (default OFF for safety reasons)"
11+ OFF )
12+
13 # when option KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES is enabled:
14 # PYTHON_EXECUTABLE can be defined when invoking cmake
15 # ( use -DPYTHON_EXECUTABLE=<python path>/python.exe or python2 )
16@@ -245,6 +249,10 @@ if( WIN32 )
17 # define UNICODE and_UNICODE definition on Windows. KiCad uses unicode.
18 # Both definitions are required
19 add_definitions(-DUNICODE -D_UNICODE)
20+
21+ # In fully standards-compliant mode, M_PI et al. are defined only if
22+ # _USE_MATH_DEFINES is set.
23+ add_definitions( -D_USE_MATH_DEFINES )
24 endif()
25
26
27@@ -357,6 +365,38 @@ if( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
28
29 endif( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
30
31+if( MSVC )
32+ # Disallow implicit linking for Boost
33+ add_definitions( -DBOOST_ALL_NO_LIB )
34+ # Disable MSVC's deprecation warnings
35+ add_definitions( -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS )
36+ # Hide Windows's min() and max() macros
37+ add_definitions( -DNOMINMAX )
38+ # source and execution charset are UTF-8
39+ string( APPEND CMAKE_CXX_FLAGS " /utf-8" )
40+ # C4290: throw() is interpreted as declspec(nothrow)
41+ string( APPEND CMAKE_CXX_FLAGS " /wd4290" )
42+ # C4800: non-bool is explicitly cast to bool, forcing value of 0 or 1
43+ string( APPEND CMAKE_CXX_FLAGS " /wd4800" )
44+ # /Zi: create PDB
45+ string( APPEND CMAKE_CXX_FLAGS " /Zi" )
46+ # /GF: enable string pooling
47+ string( APPEND CMAKE_CXX_FLAGS_RELEASE " /GF" )
48+ foreach( type EXE SHARED MODULE)
49+ # /DEBUG: create PDB
50+ string( APPEND CMAKE_${type}_LINKER_FLAGS " /DEBUG" )
51+ # /OPT:REF: omit unreferenced code
52+ string( APPEND CMAKE_${type}_LINKER_FLAGS_RELEASE " /OPT:REF" )
53+ # /OPT:ICF: fold common data
54+ string( APPEND CMAKE_${type}_LINKER_FLAGS_RELEASE " /OPT:ICF" )
55+ endforeach()
56+
57+ # Let cl.exe parallelize builds
58+ if( KICAD_BUILD_PARALLEL_CL_MP )
59+ string( APPEND CMAKE_CXX_FLAGS " /MP" )
60+ endif()
61+endif()
62+
63 if( KICAD_SCRIPTING )
64 add_definitions( -DKICAD_SCRIPTING )
65 endif()
66diff --git a/CMakeModules/FindOpenSSL.cmake b/CMakeModules/FindOpenSSL.cmake
67deleted file mode 100644
68index de91787..0000000
69--- a/CMakeModules/FindOpenSSL.cmake
70+++ /dev/null
71@@ -1,342 +0,0 @@
72-#.rst:
73-# FindOpenSSL
74-# -----------
75-#
76-# Try to find the OpenSSL encryption library
77-#
78-# Once done this will define
79-#
80-# ::
81-#
82-# OPENSSL_ROOT_DIR - Set this variable to the root installation of OpenSSL
83-#
84-#
85-#
86-# Read-Only variables:
87-#
88-# ::
89-#
90-# OPENSSL_FOUND - system has the OpenSSL library
91-# OPENSSL_INCLUDE_DIR - the OpenSSL include directory
92-# OPENSSL_LIBRARIES - The libraries needed to use OpenSSL
93-# OPENSSL_VERSION - This is set to $major.$minor.$revision$path (eg. 0.9.8s)
94-
95-#=============================================================================
96-# Copyright 2006-2009 Kitware, Inc.
97-# Copyright 2006 Alexander Neundorf <neundorf@kde.org>
98-# Copyright 2009-2011 Mathieu Malaterre <mathieu.malaterre@gmail.com>
99-#
100-# Distributed under the OSI-approved BSD License (the "License");
101-# see accompanying file Copyright.txt for details.
102-#
103-# This software is distributed WITHOUT ANY WARRANTY; without even the
104-# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
105-# See the License for more information.
106-#=============================================================================
107-# (To distribute this file outside of CMake, substitute the full
108-# License text for the above reference.)
109-
110-if (UNIX)
111- find_package(PkgConfig QUIET)
112- pkg_check_modules(_OPENSSL QUIET openssl)
113-endif ()
114-
115-if (WIN32)
116- # http://www.slproweb.com/products/Win32OpenSSL.html
117- set(_OPENSSL_ROOT_HINTS
118- ${OPENSSL_ROOT_DIR}
119- "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (32-bit)_is1;Inno Setup: App Path]"
120- "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (64-bit)_is1;Inno Setup: App Path]"
121- ENV OPENSSL_ROOT_DIR
122- )
123- file(TO_CMAKE_PATH "$ENV{PROGRAMFILES}" _programfiles)
124- set(_OPENSSL_ROOT_PATHS
125- "${_programfiles}/OpenSSL"
126- "${_programfiles}/OpenSSL-Win32"
127- "${_programfiles}/OpenSSL-Win64"
128- "C:/OpenSSL/"
129- "C:/OpenSSL-Win32/"
130- "C:/OpenSSL-Win64/"
131- )
132- unset(_programfiles)
133-else ()
134- set(_OPENSSL_ROOT_HINTS
135- ${OPENSSL_ROOT_DIR}
136- ENV OPENSSL_ROOT_DIR
137- )
138-endif ()
139-
140-set(_OPENSSL_ROOT_HINTS_AND_PATHS
141- HINTS ${_OPENSSL_ROOT_HINTS}
142- PATHS ${_OPENSSL_ROOT_PATHS}
143- )
144-
145-find_path(OPENSSL_INCLUDE_DIR
146- NAMES
147- openssl/ssl.h
148- ${_OPENSSL_ROOT_HINTS_AND_PATHS}
149- HINTS
150- ${_OPENSSL_INCLUDEDIR}
151- PATH_SUFFIXES
152- include
153-)
154-
155-if(WIN32 AND NOT CYGWIN)
156- if(MSVC)
157- # /MD and /MDd are the standard values - if someone wants to use
158- # others, the libnames have to change here too
159- # use also ssl and ssleay32 in debug as fallback for openssl < 0.9.8b
160- # TODO: handle /MT and static lib
161- # In Visual C++ naming convention each of these four kinds of Windows libraries has it's standard suffix:
162- # * MD for dynamic-release
163- # * MDd for dynamic-debug
164- # * MT for static-release
165- # * MTd for static-debug
166-
167- # Implementation details:
168- # We are using the libraries located in the VC subdir instead of the parent directory eventhough :
169- # libeay32MD.lib is identical to ../libeay32.lib, and
170- # ssleay32MD.lib is identical to ../ssleay32.lib
171- find_library(LIB_EAY_DEBUG
172- NAMES
173- libeay32MDd
174- libeay32d
175- ${_OPENSSL_ROOT_HINTS_AND_PATHS}
176- PATH_SUFFIXES
177- "lib"
178- "VC"
179- "lib/VC"
180- )
181-
182- find_library(LIB_EAY_RELEASE
183- NAMES
184- libeay32MD
185- libeay32
186- ${_OPENSSL_ROOT_HINTS_AND_PATHS}
187- PATH_SUFFIXES
188- "lib"
189- "VC"
190- "lib/VC"
191- )
192-
193- find_library(SSL_EAY_DEBUG
194- NAMES
195- ssleay32MDd
196- ssleay32d
197- ${_OPENSSL_ROOT_HINTS_AND_PATHS}
198- PATH_SUFFIXES
199- "lib"
200- "VC"
201- "lib/VC"
202- )
203-
204- find_library(SSL_EAY_RELEASE
205- NAMES
206- ssleay32MD
207- ssleay32
208- ssl
209- ${_OPENSSL_ROOT_HINTS_AND_PATHS}
210- PATH_SUFFIXES
211- "lib"
212- "VC"
213- "lib/VC"
214- )
215-
216- set(LIB_EAY_LIBRARY_DEBUG "${LIB_EAY_DEBUG}")
217- set(LIB_EAY_LIBRARY_RELEASE "${LIB_EAY_RELEASE}")
218- set(SSL_EAY_LIBRARY_DEBUG "${SSL_EAY_DEBUG}")
219- set(SSL_EAY_LIBRARY_RELEASE "${SSL_EAY_RELEASE}")
220-
221- include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake)
222- select_library_configurations(LIB_EAY)
223- select_library_configurations(SSL_EAY)
224-
225- mark_as_advanced(LIB_EAY_LIBRARY_DEBUG LIB_EAY_LIBRARY_RELEASE
226- SSL_EAY_LIBRARY_DEBUG SSL_EAY_LIBRARY_RELEASE)
227- set( OPENSSL_LIBRARIES ${SSL_EAY_LIBRARY} ${LIB_EAY_LIBRARY} )
228- elseif(MINGW)
229- message( STATUS "Searching for OpenSSL in MinGW." )
230- # same player, for MinGW
231- set(LIB_EAY_NAMES libeay32)
232- set(SSL_EAY_NAMES ssleay32)
233- list(APPEND LIB_EAY_NAMES crypto)
234- list(APPEND SSL_EAY_NAMES ssl)
235-
236- find_library(LIB_EAY
237- NAMES
238- ${LIB_EAY_NAMES}
239- ${_OPENSSL_ROOT_HINTS_AND_PATHS}
240- PATH_SUFFIXES
241- "lib"
242- "lib/MinGW"
243- # Do not search system path. Otherwise the DLL will be found rather than the link library.
244- NO_SYSTEM_ENVIRONMENT_PATH
245- NO_CMAKE_SYSTEM_PATH
246- )
247-
248- find_library(SSL_EAY
249- NAMES
250- ${SSL_EAY_NAMES}
251- ${_OPENSSL_ROOT_HINTS_AND_PATHS}
252- PATH_SUFFIXES
253- "lib"
254- "lib/MinGW"
255- # Do not search system path. Otherwise the DLL will be found rather than the link library.
256- NO_SYSTEM_ENVIRONMENT_PATH
257- NO_CMAKE_SYSTEM_PATH
258- )
259-
260- mark_as_advanced(SSL_EAY LIB_EAY)
261- set( OPENSSL_LIBRARIES ${SSL_EAY} ${LIB_EAY} )
262- unset(LIB_EAY_NAMES)
263- unset(SSL_EAY_NAMES)
264- else()
265- # Not sure what to pick for -say- intel, let's use the toplevel ones and hope someone report issues:
266- find_library(LIB_EAY
267- NAMES
268- libeay32
269- ${_OPENSSL_ROOT_HINTS_AND_PATHS}
270- HINTS
271- ${_OPENSSL_LIBDIR}
272- PATH_SUFFIXES
273- lib
274- )
275-
276- find_library(SSL_EAY
277- NAMES
278- ssleay32
279- ${_OPENSSL_ROOT_HINTS_AND_PATHS}
280- HINTS
281- ${_OPENSSL_LIBDIR}
282- PATH_SUFFIXES
283- lib
284- )
285-
286- mark_as_advanced(SSL_EAY LIB_EAY)
287- set( OPENSSL_LIBRARIES ${SSL_EAY} ${LIB_EAY} )
288- endif()
289-else()
290-
291- find_library(OPENSSL_SSL_LIBRARY
292- NAMES
293- ssl
294- ssleay32
295- ssleay32MD
296- ${_OPENSSL_ROOT_HINTS_AND_PATHS}
297- HINTS
298- ${_OPENSSL_LIBDIR}
299- PATH_SUFFIXES
300- lib
301- )
302-
303- find_library(OPENSSL_CRYPTO_LIBRARY
304- NAMES
305- crypto
306- ${_OPENSSL_ROOT_HINTS_AND_PATHS}
307- HINTS
308- ${_OPENSSL_LIBDIR}
309- PATH_SUFFIXES
310- lib
311- )
312-
313- mark_as_advanced(OPENSSL_CRYPTO_LIBRARY OPENSSL_SSL_LIBRARY)
314-
315- # compat defines
316- set(OPENSSL_SSL_LIBRARIES ${OPENSSL_SSL_LIBRARY})
317- set(OPENSSL_CRYPTO_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY})
318-
319- set(OPENSSL_LIBRARIES ${OPENSSL_SSL_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY})
320-
321-endif()
322-
323-function(from_hex HEX DEC)
324- string(TOUPPER "${HEX}" HEX)
325- set(_res 0)
326- string(LENGTH "${HEX}" _strlen)
327-
328- while (_strlen GREATER 0)
329- math(EXPR _res "${_res} * 16")
330- string(SUBSTRING "${HEX}" 0 1 NIBBLE)
331- string(SUBSTRING "${HEX}" 1 -1 HEX)
332- if (NIBBLE STREQUAL "A")
333- math(EXPR _res "${_res} + 10")
334- elseif (NIBBLE STREQUAL "B")
335- math(EXPR _res "${_res} + 11")
336- elseif (NIBBLE STREQUAL "C")
337- math(EXPR _res "${_res} + 12")
338- elseif (NIBBLE STREQUAL "D")
339- math(EXPR _res "${_res} + 13")
340- elseif (NIBBLE STREQUAL "E")
341- math(EXPR _res "${_res} + 14")
342- elseif (NIBBLE STREQUAL "F")
343- math(EXPR _res "${_res} + 15")
344- else()
345- math(EXPR _res "${_res} + ${NIBBLE}")
346- endif()
347-
348- string(LENGTH "${HEX}" _strlen)
349- endwhile()
350-
351- set(${DEC} ${_res} PARENT_SCOPE)
352-endfunction()
353-
354-if (OPENSSL_INCLUDE_DIR)
355- if (_OPENSSL_VERSION)
356- set(OPENSSL_VERSION "${_OPENSSL_VERSION}")
357- elseif(OPENSSL_INCLUDE_DIR AND EXISTS "${OPENSSL_INCLUDE_DIR}/openssl/opensslv.h")
358- file(STRINGS "${OPENSSL_INCLUDE_DIR}/openssl/opensslv.h" openssl_version_str
359- REGEX "^#[\t ]*define[\t ]+OPENSSL_VERSION_NUMBER[\t ]+0x([0-9a-fA-F])+.*")
360-
361- # The version number is encoded as 0xMNNFFPPS: major minor fix patch status
362- # The status gives if this is a developer or prerelease and is ignored here.
363- # Major, minor, and fix directly translate into the version numbers shown in
364- # the string. The patch field translates to the single character suffix that
365- # indicates the bug fix state, which 00 -> nothing, 01 -> a, 02 -> b and so
366- # on.
367-
368- message(STATUS "OPENSSL_VERSION_STR=${openssl_version_str}")
369-
370- string(REGEX REPLACE "^.*OPENSSL_VERSION_NUMBER[\t ]+0x([0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F]).*$"
371- "\\1;\\2;\\3;\\4;\\5" OPENSSL_VERSION_LIST "${openssl_version_str}")
372- list(GET OPENSSL_VERSION_LIST 0 OPENSSL_VERSION_MAJOR)
373- list(GET OPENSSL_VERSION_LIST 1 OPENSSL_VERSION_MINOR)
374- from_hex("${OPENSSL_VERSION_MINOR}" OPENSSL_VERSION_MINOR)
375- list(GET OPENSSL_VERSION_LIST 2 OPENSSL_VERSION_FIX)
376- from_hex("${OPENSSL_VERSION_FIX}" OPENSSL_VERSION_FIX)
377- list(GET OPENSSL_VERSION_LIST 3 OPENSSL_VERSION_PATCH)
378-
379- if (NOT OPENSSL_VERSION_PATCH STREQUAL "00")
380- from_hex("${OPENSSL_VERSION_PATCH}" _tmp)
381- # 96 is the ASCII code of 'a' minus 1
382- math(EXPR OPENSSL_VERSION_PATCH_ASCII "${_tmp} + 96")
383- unset(_tmp)
384- # Once anyone knows how OpenSSL would call the patch versions beyond 'z'
385- # this should be updated to handle that, too. This has not happened yet
386- # so it is simply ignored here for now.
387- string(ASCII "${OPENSSL_VERSION_PATCH_ASCII}" OPENSSL_VERSION_PATCH_STRING)
388- endif ()
389-
390- set(OPENSSL_VERSION "${OPENSSL_VERSION_MAJOR}.${OPENSSL_VERSION_MINOR}.${OPENSSL_VERSION_FIX}${OPENSSL_VERSION_PATCH_STRING}")
391- endif ()
392-endif ()
393-
394-include(FindPackageHandleStandardArgs)
395-
396-if (OPENSSL_VERSION)
397- find_package_handle_standard_args(OpenSSL
398- REQUIRED_VARS
399- OPENSSL_LIBRARIES
400- OPENSSL_INCLUDE_DIR
401- VERSION_VAR
402- OPENSSL_VERSION
403- FAIL_MESSAGE
404- "Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR"
405- )
406-else ()
407- find_package_handle_standard_args(OpenSSL "Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR"
408- OPENSSL_LIBRARIES
409- OPENSSL_INCLUDE_DIR
410- )
411-endif ()
412-
413-mark_as_advanced(OPENSSL_INCLUDE_DIR OPENSSL_LIBRARIES)
414diff --git a/common/gal/cairo/cairo_print.cpp b/common/gal/cairo/cairo_print.cpp
415index 0204c69..6cef33e 100644
416--- a/common/gal/cairo/cairo_print.cpp
417+++ b/common/gal/cairo/cairo_print.cpp
418@@ -25,6 +25,12 @@
419 #include <wx/dcmemory.h>
420 #include <wx/dcprint.h>
421
422+#ifdef NOMINMAX /* workaround for gdiplus.h */
423+#include <algorithm>
424+using std::min;
425+using std::max;
426+#endif
427+
428 #ifdef __WXMSW__
429 #include <windows.h>
430 #include <gdiplus.h>
431diff --git a/common/system/libcontext.cpp b/common/system/libcontext.cpp
432index f6f83ce..57478f1 100644
433--- a/common/system/libcontext.cpp
434+++ b/common/system/libcontext.cpp
435@@ -13,6 +13,8 @@
436 http://www.boost.org/LICENSE_1_0.txt)
437
438 */
439+#include <stdlib.h>
440+#include <setjmp.h>
441 #include <system/libcontext.h>
442
443 #if defined(LIBCONTEXT_PLATFORM_windows_i386) && defined(LIBCONTEXT_COMPILER_gcc)
444@@ -1268,3 +1270,67 @@ __asm (
445 );
446
447 #endif
448+
449+#if defined(LIBCONTEXT_PLATFORM_msvc_x86_64) || defined(LIBCONTEXT_PLATFORM_msvc_i386)
450+
451+#include <map>
452+
453+#ifdef __cplusplus
454+extern "C" {
455+#endif
456+
457+#include <windows.h>
458+
459+namespace libcontext
460+{
461+
462+static int threadHasFibers = 0;
463+
464+struct FiberData
465+{
466+ intptr_t inValue;
467+ intptr_t outValue;
468+ void(*entry)(intptr_t);
469+};
470+
471+static std::map<fcontext_t, FiberData> fiberParams;
472+
473+static void fiberEntry(LPVOID params)
474+{
475+ auto ctx = (fcontext_t) GetCurrentFiber();
476+ auto& d = fiberParams[ctx];
477+ d.entry(d.inValue);
478+}
479+
480+fcontext_t LIBCONTEXT_CALL_CONVENTION make_fcontext(void* sp, size_t size, void(*fn)(intptr_t))
481+{
482+ if (!threadHasFibers)
483+ {
484+ ConvertThreadToFiber(nullptr);
485+ threadHasFibers = 1;
486+ }
487+
488+ fcontext_t ctx = CreateFiber(size, (LPFIBER_START_ROUTINE) fiberEntry, nullptr );
489+ fiberParams[ctx].entry = fn;
490+
491+ return ctx;
492+}
493+
494+intptr_t LIBCONTEXT_CALL_CONVENTION jump_fcontext(fcontext_t* ofc, fcontext_t nfc,
495+ intptr_t vp, bool preserve_fpu)
496+{
497+ auto current = (void*)GetCurrentFiber();
498+ fiberParams[current].outValue = vp;
499+ *ofc = GetCurrentFiber();
500+ fiberParams[nfc].inValue = vp;
501+ SwitchToFiber(nfc);
502+ return fiberParams[*ofc].outValue;
503+}
504+
505+}; // namespace libcontext
506+
507+#ifdef __cplusplus
508+};
509+#endif
510+
511+#endif
512diff --git a/eeschema/sim/ngspice.cpp b/eeschema/sim/ngspice.cpp
513index fa1d3e3..4b173ef 100644
514--- a/eeschema/sim/ngspice.cpp
515+++ b/eeschema/sim/ngspice.cpp
516@@ -28,6 +28,7 @@
517 #include "ngspice.h"
518 #include "spice_reporter.h"
519
520+#include <config.h>
521 #include <common.h> // LOCALE_IO
522 #include <wx/stdpaths.h>
523 #include <wx/dir.h>
524diff --git a/include/lib_tree_item.h b/include/lib_tree_item.h
525index 5ad5ef4..28f69b7 100644
526--- a/include/lib_tree_item.h
527+++ b/include/lib_tree_item.h
528@@ -27,7 +27,7 @@
529
530 #include <base_struct.h>
531 #include <lib_id.h>
532-
533+#include <import_export.h>
534
535 /**
536 * A mix-in to provide polymorphism between items stored in libraries (symbols, aliases
537@@ -36,7 +36,7 @@
538 * It is used primarily to drive the component tree for library browsing and editing.
539 */
540
541-class LIB_TREE_ITEM
542+class APIEXPORT LIB_TREE_ITEM
543 {
544 public:
545 virtual LIB_ID GetLibId() const = 0;
546diff --git a/include/system/libcontext.h b/include/system/libcontext.h
547index 8045fa2..dfa323d 100644
548--- a/include/system/libcontext.h
549+++ b/include/system/libcontext.h
550@@ -24,6 +24,8 @@
551
552 #if defined(__GNUC__) || defined(__APPLE__) || defined(__FreeBSD__)
553
554+ #undef LIBCONTEXT_HAS_OWN_STACK
555+
556 #define LIBCONTEXT_COMPILER_gcc
557
558 #if defined(__linux__) || defined(__FreeBSD__)
559@@ -46,7 +48,8 @@
560 #ifdef _ARCH_PPC64
561 #define LIBCONTEXT_PLATFORM_linux_ppc64
562 #define LIBCONTEXT_CALL_CONVENTION
563- #elif defined _ARCH_PPC
564+ #endif
565+ #ifdef _ARCH_PPC
566 #define LIBCONTEXT_PLATFORM_linux_ppc32
567 #define LIBCONTEXT_CALL_CONVENTION
568 #endif
569@@ -73,6 +76,17 @@
570 #define LIBCONTEXT_CALL_CONVENTION
571 #endif
572 #endif
573+#elif defined (_MSC_VER)
574+
575+#define LIBCONTEXT_HAS_OWN_STACK
576+
577+#define LIBCONTEXT_CALL_CONVENTION __cdecl
578+
579+#if defined(_WIN64)
580+ #define LIBCONTEXT_PLATFORM_msvc_x86_64
581+#elif defined(_WIN32)
582+ #define LIBCONTEXT_PLATFORM_msvc_i386
583+#endif
584 #endif
585
586 #ifdef __cplusplus
587diff --git a/include/tool/coroutine.h b/include/tool/coroutine.h
588index 7be173a..60144eb 100644
589--- a/include/tool/coroutine.h
590+++ b/include/tool/coroutine.h
591@@ -294,15 +294,19 @@ private:
592
593 assert( m_stack == nullptr );
594
595- // fixme: Clean up stack stuff. Add a guard
596 size_t stackSize = c_defaultStackSize;
597+ void* sp = nullptr;
598+
599+ #ifndef LIBCONTEXT_HAS_OWN_STACK
600+ // fixme: Clean up stack stuff. Add a guard
601 m_stack.reset( new char[stackSize] );
602
603 // align to 16 bytes
604- void* sp = (void*)((((ptrdiff_t) m_stack.get()) + stackSize - 0xf) & (~0x0f));
605+ sp = (void*)((((ptrdiff_t) m_stack.get()) + stackSize - 0xf) & (~0x0f));
606
607 // correct the stack size
608 stackSize -= size_t( ( (ptrdiff_t) m_stack.get() + stackSize ) - (ptrdiff_t) sp );
609+ #endif
610
611 m_callee = libcontext::make_fcontext( sp, stackSize, callerStub );
612 m_running = true;
613diff --git a/pcbnew/pcb_edit_frame.h b/pcbnew/pcb_edit_frame.h
614index 705f5f7..dadb6cb 100644
615--- a/pcbnew/pcb_edit_frame.h
616+++ b/pcbnew/pcb_edit_frame.h
617@@ -93,6 +93,7 @@ protected:
618 PCB_LAYER_WIDGET* m_Layers;
619
620 PARAM_CFG_ARRAY m_configParams; ///< List of Pcbnew configuration settings.
621+ PARAM_CFG_ARRAY m_projectFileParams;
622
623 wxString m_lastNetListRead; ///< Last net list read with relative path.
624
625@@ -379,7 +380,7 @@ public:
626 * @return PARAM_CFG_ARRAY - it is only good until SetBoard() is called, so
627 * don't keep it around past that event.
628 */
629- PARAM_CFG_ARRAY GetProjectFileParameters();
630+ PARAM_CFG_ARRAY& GetProjectFileParameters();
631
632 /**
633 * Function SaveProjectSettings
634diff --git a/pcbnew/pcbnew_config.cpp b/pcbnew/pcbnew_config.cpp
635index ff1cb57..8b57753 100644
636--- a/pcbnew/pcbnew_config.cpp
637+++ b/pcbnew/pcbnew_config.cpp
638@@ -125,21 +125,21 @@ void PCB_EDIT_FRAME::SaveProjectSettings( bool aAskForSave )
639 }
640
641
642-PARAM_CFG_ARRAY PCB_EDIT_FRAME::GetProjectFileParameters()
643+PARAM_CFG_ARRAY& PCB_EDIT_FRAME::GetProjectFileParameters()
644 {
645- PARAM_CFG_ARRAY pca;
646+ m_projectFileParams.clear();
647
648 // This one cannot be cached because some settings are going to/from the BOARD,
649 // so pointers into that cannot be saved for long.
650
651- pca.push_back( new PARAM_CFG_FILENAME( wxT( "PageLayoutDescrFile" ),
652+ m_projectFileParams.push_back( new PARAM_CFG_FILENAME( wxT( "PageLayoutDescrFile" ),
653 &BASE_SCREEN::m_PageLayoutDescrFileName ) );
654
655- pca.push_back( new PARAM_CFG_FILENAME( wxT( "LastNetListRead" ), &m_lastNetListRead ) );
656+ m_projectFileParams.push_back( new PARAM_CFG_FILENAME( wxT( "LastNetListRead" ), &m_lastNetListRead ) );
657
658- GetBoard()->GetDesignSettings().AppendConfigs( GetBoard(), &pca );
659+ GetBoard()->GetDesignSettings().AppendConfigs( GetBoard(), &m_projectFileParams);
660
661- return pca;
662+ return m_projectFileParams;
663 }
664
665

Subscribers

People subscribed via source and target branches

to status/vote changes: