From 01dd7804b87d60b2deab16712eccb3b97351a9b7 Mon Sep 17 00:00:00 2001 From: Damien George Date: Wed, 6 Sep 2017 13:40:51 +1000 Subject: ports: Make new ports/ sub-directory and move all ports there. This is to keep the top-level directory clean, to make it clear what is core and what is a port, and to allow the repository to grow with new ports in a sustainable way. --- windows/.appveyor.yml | 32 ------ windows/.gitignore | 11 -- windows/Makefile | 65 ------------ windows/README.md | 74 ------------- windows/fmode.c | 49 --------- windows/fmode.h | 37 ------- windows/init.c | 69 ------------ windows/init.h | 32 ------ windows/micropython.vcxproj | 104 ------------------ windows/mpconfigport.h | 251 -------------------------------------------- windows/mpconfigport.mk | 10 -- windows/msvc/common.props | 47 --------- windows/msvc/debug.props | 9 -- windows/msvc/dirent.c | 103 ------------------ windows/msvc/dirent.h | 48 --------- windows/msvc/genhdr.targets | 117 --------------------- windows/msvc/gettimeofday.c | 58 ---------- windows/msvc/paths.props | 45 -------- windows/msvc/release.props | 16 --- windows/msvc/sources.props | 37 ------- windows/msvc/sys/time.h | 32 ------ windows/msvc/unistd.h | 44 -------- windows/realpath.c | 64 ----------- windows/realpath.h | 31 ------ windows/sleep.c | 76 -------------- windows/sleep.h | 36 ------- windows/windows_mphal.c | 229 ---------------------------------------- windows/windows_mphal.h | 36 ------- 28 files changed, 1762 deletions(-) delete mode 100644 windows/.appveyor.yml delete mode 100644 windows/.gitignore delete mode 100644 windows/Makefile delete mode 100644 windows/README.md delete mode 100644 windows/fmode.c delete mode 100644 windows/fmode.h delete mode 100644 windows/init.c delete mode 100644 windows/init.h delete mode 100644 windows/micropython.vcxproj delete mode 100644 windows/mpconfigport.h delete mode 100644 windows/mpconfigport.mk delete mode 100644 windows/msvc/common.props delete mode 100644 windows/msvc/debug.props delete mode 100644 windows/msvc/dirent.c delete mode 100644 windows/msvc/dirent.h delete mode 100644 windows/msvc/genhdr.targets delete mode 100644 windows/msvc/gettimeofday.c delete mode 100644 windows/msvc/paths.props delete mode 100644 windows/msvc/release.props delete mode 100644 windows/msvc/sources.props delete mode 100644 windows/msvc/sys/time.h delete mode 100644 windows/msvc/unistd.h delete mode 100644 windows/realpath.c delete mode 100644 windows/realpath.h delete mode 100644 windows/sleep.c delete mode 100644 windows/sleep.h delete mode 100644 windows/windows_mphal.c delete mode 100644 windows/windows_mphal.h (limited to 'windows') diff --git a/windows/.appveyor.yml b/windows/.appveyor.yml deleted file mode 100644 index 84060a116..000000000 --- a/windows/.appveyor.yml +++ /dev/null @@ -1,32 +0,0 @@ -environment: - # Python version used - MICROPY_CPYTHON3: c:/python34/python.exe - -init: - # Set build version number to commit to be travis-like -- ps: Update-AppveyorBuild -Version $env:appveyor_repo_commit.substring(0,8) - -configuration: -- Debug -- Release - -platform: -- x86 -- x64 - -build: - project: windows/micropython.vcxproj - verbosity: normal - -test_script: -- cmd: >- - cd tests - - %MICROPY_CPYTHON3% run-tests - -skip_tags: true - -deploy: off - -nuget: - disable_publish_on_pr: true diff --git a/windows/.gitignore b/windows/.gitignore deleted file mode 100644 index 12235e7c9..000000000 --- a/windows/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -*.user -*.*sdf -*.suo -*.sln -*.exe -*.pdb -*.ilk -*.filters -/build/* -.vs/* -*.VC.*db diff --git a/windows/Makefile b/windows/Makefile deleted file mode 100644 index a39d34826..000000000 --- a/windows/Makefile +++ /dev/null @@ -1,65 +0,0 @@ -include ../py/mkenv.mk --include mpconfigport.mk - -# define main target -PROG = micropython.exe - -# qstr definitions (must come before including py.mk) -QSTR_DEFS = ../unix/qstrdefsport.h - -# include py core make definitions -include $(TOP)/py/py.mk - -INC += -I. -INC += -I$(TOP) -INC += -I$(BUILD) - -# compiler settings -CFLAGS = $(INC) -Wall -Wpointer-arith -Werror -std=gnu99 -DUNIX -D__USE_MINGW_ANSI_STDIO=1 $(CFLAGS_MOD) $(COPT) -LDFLAGS = $(LDFLAGS_MOD) -lm - -# Debugging/Optimization -ifdef DEBUG -CFLAGS += -g -COPT = -O0 -else -COPT = -Os #-DNDEBUG -endif - -# source files -SRC_C = \ - unix/main.c \ - unix/file.c \ - unix/input.c \ - unix/modos.c \ - unix/modmachine.c \ - unix/modtime.c \ - unix/gccollect.c \ - windows_mphal.c \ - realpath.c \ - init.c \ - sleep.c \ - -OBJ = $(PY_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o)) - -ifeq ($(MICROPY_USE_READLINE),1) -CFLAGS_MOD += -DMICROPY_USE_READLINE=1 -SRC_C += lib/mp-readline/readline.c -else ifeq ($(MICROPY_USE_READLINE),2) -CFLAGS_MOD += -DMICROPY_USE_READLINE=2 -LDFLAGS_MOD += -lreadline -endif - -ifeq ($(CROSS_COMPILE),x86_64-w64-mingw32-) -CFLAGS_MOD += -DMICROPY_NLR_SETJMP=1 -endif - -LIB += -lws2_32 - -# List of sources for qstr extraction -SRC_QSTR += $(SRC_C) -# Append any auto-generated sources that are needed by sources listed in -# SRC_QSTR -SRC_QSTR_AUTO_DEPS += - -include $(TOP)/py/mkrules.mk diff --git a/windows/README.md b/windows/README.md deleted file mode 100644 index 6d3249903..000000000 --- a/windows/README.md +++ /dev/null @@ -1,74 +0,0 @@ -This is the experimental, community-supported Windows port of MicroPython. -It is based on Unix port, and expected to remain so. -The port requires additional testing, debugging, and patches. Please -consider to contribute. - - -Building on Debian/Ubuntu Linux system ---------------------------------------- - - sudo apt-get install gcc-mingw-w64 - make CROSS_COMPILE=i686-w64-mingw32- - -If for some reason the mingw-w64 crosscompiler is not available, you can try -mingw32 instead, but it comes with a really old gcc which may produce some -spurious errors (you may need to disable -Werror): - - sudo apt-get install mingw32 mingw32-binutils mingw32-runtime - make CROSS_COMPILE=i586-mingw32msvc- - - -Building under Cygwin ---------------------- - -Install following packages using cygwin's setup.exe: - -* mingw64-i686-gcc-core -* mingw64-x86_64-gcc-core -* make - -Build using: - - make CROSS_COMPILE=i686-w64-mingw32- - -Or for 64bit: - - make CROSS_COMPILE=x86_64-w64-mingw32- - - -Building using MS Visual Studio 2013 (or higher) ------------------------------------------------- - -In the IDE, open `micropython.vcxproj` and build. - -To build from the command line: - - msbuild micropython.vcxproj - -__Stack usage__ - -The msvc compiler is quite stack-hungry which might result in a "maximum recursion depth exceeded" -RuntimeError for code with lots of nested function calls. -There are several ways to deal with this: -- increase the threshold used for detection by altering the argument to `mp_stack_set_limit` in `unix/main.c` -- disable detection all together by setting `MICROPY_STACK_CHECK` to "0" in `windows/mpconfigport.h` -- disable the /GL compiler flag by setting `WholeProgramOptimization` to "false" - -See [issue 2927](https://github.com/micropython/micropython/issues/2927) for more information. - - -Running on Linux using Wine ---------------------------- - -The default build (MICROPY_USE_READLINE=1) uses extended Windows console -functions and thus should be ran using the `wineconsole` tool. Depending -on the Wine build configuration, you may also want to select the curses -backend which has the look&feel of a standard Unix console: - - wineconsole --backend=curses ./micropython.exe - -For more info, see https://www.winehq.org/docs/wineusr-guide/cui-programs . - -If built without line editing and history capabilities -(MICROPY_USE_READLINE=0), the resulting binary can be run using the standard -`wine` tool. diff --git a/windows/fmode.c b/windows/fmode.c deleted file mode 100644 index 33ba24ed1..000000000 --- a/windows/fmode.c +++ /dev/null @@ -1,49 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2013-2016 Damien P. George - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#include "fmode.h" -#include "py/mpconfig.h" -#include -#include - -// Workaround for setting file translation mode: we must distinguish toolsets -// since mingw has no _set_fmode, and altering msvc's _fmode directly has no effect -STATIC int set_fmode_impl(int mode) { -#ifndef _MSC_VER - _fmode = mode; - return 0; -#else - return _set_fmode(mode); -#endif -} - -void set_fmode_binary(void) { - set_fmode_impl(O_BINARY); -} - -void set_fmode_text(void) { - set_fmode_impl(O_TEXT); -} diff --git a/windows/fmode.h b/windows/fmode.h deleted file mode 100644 index c661c84d0..000000000 --- a/windows/fmode.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2013-2016 Damien P. George - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -#ifndef MICROPY_INCLUDED_WINDOWS_FMODE_H -#define MICROPY_INCLUDED_WINDOWS_FMODE_H - -// Treat files opened by open() as binary. No line ending translation is done. -void set_fmode_binary(void); - -// Treat files opened by open() as text. -// When reading from the file \r\n will be converted to \n. -// When writing to the file \n will be converted into \r\n. -void set_fmode_text(void); - -#endif // MICROPY_INCLUDED_WINDOWS_FMODE_H diff --git a/windows/init.c b/windows/init.c deleted file mode 100644 index 09fa10417..000000000 --- a/windows/init.c +++ /dev/null @@ -1,69 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2013, 2014 Damien P. George - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#include -#include -#include -#ifdef _MSC_VER -#include -#endif -#include "sleep.h" - -extern BOOL WINAPI console_sighandler(DWORD evt); - -#ifdef _MSC_VER -void invalid_param_handler(const wchar_t *expr, const wchar_t *fun, const wchar_t *file, unsigned int line, uintptr_t p) { -} -#endif - -void init() { -#ifdef _MSC_VER - // Disable the 'Debug Error!' dialog for assertions failures and the likes, - // instead write messages to the debugger output and terminate. - _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG); - _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG); - _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG); - - // Disable 'invalid parameter handling' which is for instance invoked when - // passing invalid file descriptors to functions like lseek() and make the - // functions called behave properly by setting errno to EBADF/EINVAL/.. - _set_invalid_parameter_handler(invalid_param_handler); -#endif - SetConsoleCtrlHandler(console_sighandler, TRUE); - init_sleep(); -#ifdef __MINGW32__ - putenv("PRINTF_EXPONENT_DIGITS=2"); -#elif _MSC_VER < 1900 - // This is only necessary for Visual Studio versions 2013 and below: - // https://msdn.microsoft.com/en-us/library/bb531344(v=vs.140).aspx - _set_output_format(_TWO_DIGIT_EXPONENT); -#endif -} - -void deinit() { - SetConsoleCtrlHandler(console_sighandler, FALSE); - deinit_sleep(); -} diff --git a/windows/init.h b/windows/init.h deleted file mode 100644 index c6fddb257..000000000 --- a/windows/init.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2013, 2014 Damien P. George - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -#ifndef MICROPY_INCLUDED_WINDOWS_INIT_H -#define MICROPY_INCLUDED_WINDOWS_INIT_H - -void init(void); -void deinit(void); - -#endif // MICROPY_INCLUDED_WINDOWS_INIT_H diff --git a/windows/micropython.vcxproj b/windows/micropython.vcxproj deleted file mode 100644 index ee0b98abb..000000000 --- a/windows/micropython.vcxproj +++ /dev/null @@ -1,104 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - {740F3C30-EB6C-4B59-9C50-AE4D5A4A9D12} - micropython - - - - Application - true - $(DefaultPlatformToolset) - MultiByte - - - Application - false - $(DefaultPlatformToolset) - true - MultiByte - - - Application - true - $(DefaultPlatformToolset) - MultiByte - - - Application - false - $(DefaultPlatformToolset) - true - MultiByte - - - - - - - - - - - - - - - - - - - - - - - - - - msvc/user.props - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/windows/mpconfigport.h b/windows/mpconfigport.h deleted file mode 100644 index abad35282..000000000 --- a/windows/mpconfigport.h +++ /dev/null @@ -1,251 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2013, 2014 Damien P. George - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -// options to control how MicroPython is built - -// Linking with GNU readline (MICROPY_USE_READLINE == 2) causes binary to be licensed under GPL -#ifndef MICROPY_USE_READLINE -#define MICROPY_USE_READLINE (1) -#endif - -#define MICROPY_ALLOC_PATH_MAX (260) //see minwindef.h for msvc or limits.h for mingw -#define MICROPY_PERSISTENT_CODE_LOAD (1) -#define MICROPY_EMIT_X64 (0) -#define MICROPY_EMIT_THUMB (0) -#define MICROPY_EMIT_INLINE_THUMB (0) -#define MICROPY_COMP_MODULE_CONST (1) -#define MICROPY_COMP_TRIPLE_TUPLE_ASSIGN (1) -#define MICROPY_COMP_RETURN_IF_EXPR (1) -#define MICROPY_ENABLE_GC (1) -#define MICROPY_ENABLE_FINALISER (1) -#define MICROPY_STACK_CHECK (1) -#define MICROPY_MALLOC_USES_ALLOCATED_SIZE (1) -#define MICROPY_MEM_STATS (1) -#define MICROPY_DEBUG_PRINTERS (1) -#define MICROPY_DEBUG_PRINTER_DEST mp_stderr_print -#define MICROPY_READER_POSIX (1) -#define MICROPY_USE_READLINE_HISTORY (1) -#define MICROPY_HELPER_REPL (1) -#define MICROPY_REPL_EMACS_KEYS (1) -#define MICROPY_REPL_AUTO_INDENT (1) -#define MICROPY_HELPER_LEXER_UNIX (1) -#define MICROPY_ENABLE_SOURCE_LINE (1) -#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_DOUBLE) -#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ) -#define MICROPY_STREAMS_NON_BLOCK (1) -#define MICROPY_OPT_COMPUTED_GOTO (0) -#define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE (1) -#define MICROPY_CAN_OVERRIDE_BUILTINS (1) -#define MICROPY_PY_FUNCTION_ATTRS (1) -#define MICROPY_PY_DESCRIPTORS (1) -#define MICROPY_PY_BUILTINS_STR_UNICODE (1) -#define MICROPY_PY_BUILTINS_STR_CENTER (1) -#define MICROPY_PY_BUILTINS_STR_PARTITION (1) -#define MICROPY_PY_BUILTINS_STR_SPLITLINES (1) -#define MICROPY_PY_BUILTINS_MEMORYVIEW (1) -#define MICROPY_PY_BUILTINS_FROZENSET (1) -#define MICROPY_PY_BUILTINS_COMPILE (1) -#define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (1) -#define MICROPY_PY_BUILTINS_INPUT (1) -#define MICROPY_PY_BUILTINS_POW3 (1) -#define MICROPY_PY_MICROPYTHON_MEM_INFO (1) -#define MICROPY_PY_ALL_SPECIAL_METHODS (1) -#define MICROPY_PY_ARRAY_SLICE_ASSIGN (1) -#define MICROPY_PY_BUILTINS_SLICE_ATTRS (1) -#define MICROPY_PY_SYS_EXIT (1) -#define MICROPY_PY_SYS_PLATFORM "win32" -#define MICROPY_PY_SYS_MAXSIZE (1) -#define MICROPY_PY_SYS_STDFILES (1) -#define MICROPY_PY_SYS_EXC_INFO (1) -#define MICROPY_PY_COLLECTIONS_ORDEREDDICT (1) -#define MICROPY_PY_MATH_SPECIAL_FUNCTIONS (1) -#define MICROPY_PY_CMATH (1) -#define MICROPY_PY_IO_FILEIO (1) -#define MICROPY_PY_GC_COLLECT_RETVAL (1) -#define MICROPY_MODULE_FROZEN_STR (0) - -#define MICROPY_STACKLESS (0) -#define MICROPY_STACKLESS_STRICT (0) - -#define MICROPY_PY_UTIME (1) -#define MICROPY_PY_UTIME_MP_HAL (1) -#define MICROPY_PY_UERRNO (1) -#define MICROPY_PY_UCTYPES (1) -#define MICROPY_PY_UZLIB (1) -#define MICROPY_PY_UJSON (1) -#define MICROPY_PY_URE (1) -#define MICROPY_PY_UHEAPQ (1) -#define MICROPY_PY_UTIMEQ (1) -#define MICROPY_PY_UHASHLIB (1) -#define MICROPY_PY_UBINASCII (1) -#define MICROPY_PY_UBINASCII_CRC32 (1) -#define MICROPY_PY_URANDOM (1) -#define MICROPY_PY_MACHINE (1) -#define MICROPY_PY_MACHINE_PULSE (1) -#define MICROPY_MACHINE_MEM_GET_READ_ADDR mod_machine_mem_get_addr -#define MICROPY_MACHINE_MEM_GET_WRITE_ADDR mod_machine_mem_get_addr - -#define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_DETAILED) -#define MICROPY_WARNINGS (1) -#define MICROPY_PY_STR_BYTES_CMP_WARN (1) - -#ifdef _MSC_VER -#define MICROPY_GCREGS_SETJMP (1) -#endif - -#define MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF (1) -#define MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE (256) -#define MICROPY_KBD_EXCEPTION (1) - -#define MICROPY_PORT_INIT_FUNC init() -#define MICROPY_PORT_DEINIT_FUNC deinit() - -// type definitions for the specific machine - -#if defined( __MINGW32__ ) && defined( __LP64__ ) -typedef long mp_int_t; // must be pointer size -typedef unsigned long mp_uint_t; // must be pointer size -#elif defined ( __MINGW32__ ) && defined( _WIN64 ) -#include -typedef __int64 mp_int_t; -typedef unsigned __int64 mp_uint_t; -#define MP_SSIZE_MAX __INT64_MAX__ -#elif defined ( _MSC_VER ) && defined( _WIN64 ) -typedef __int64 mp_int_t; -typedef unsigned __int64 mp_uint_t; -#else -// These are definitions for machines where sizeof(int) == sizeof(void*), -// regardless for actual size. -typedef int mp_int_t; // must be pointer size -typedef unsigned int mp_uint_t; // must be pointer size -#endif - -// Just assume Windows is little-endian - mingw32 gcc doesn't -// define standard endianness macros. -#define MP_ENDIANNESS_LITTLE (1) - -// Cannot include , as it may lead to symbol name clashes -#if _FILE_OFFSET_BITS == 64 && !defined(__LP64__) -typedef long long mp_off_t; -#else -typedef long mp_off_t; -#endif - -#if MICROPY_PY_OS_DUPTERM -#define MP_PLAT_PRINT_STRN(str, len) mp_hal_stdout_tx_strn_cooked(str, len) -void mp_hal_dupterm_tx_strn(const char *str, size_t len); -#else -#include -#define MP_PLAT_PRINT_STRN(str, len) do { int ret = write(1, str, len); (void)ret; } while (0) -#define mp_hal_dupterm_tx_strn(s, l) -#endif - -#define MICROPY_PORT_BUILTINS \ - { MP_ROM_QSTR(MP_QSTR_open), MP_ROM_PTR(&mp_builtin_open_obj) }, - -extern const struct _mp_obj_module_t mp_module_os; -extern const struct _mp_obj_module_t mp_module_time; -#define MICROPY_PORT_BUILTIN_MODULES \ - { MP_ROM_QSTR(MP_QSTR_utime), MP_ROM_PTR(&mp_module_time) }, \ - { MP_ROM_QSTR(MP_QSTR_umachine), MP_ROM_PTR(&mp_module_machine) }, \ - { MP_ROM_QSTR(MP_QSTR_uos), MP_ROM_PTR(&mp_module_os) }, \ - -#if MICROPY_USE_READLINE == 1 -#define MICROPY_PORT_ROOT_POINTERS \ - char *readline_hist[50]; -#endif - -#define MP_STATE_PORT MP_STATE_VM - -#define MICROPY_MPHALPORT_H "windows_mphal.h" - -// We need to provide a declaration/definition of alloca() -#include - -#include "realpath.h" -#include "init.h" -#include "sleep.h" - -#ifdef __GNUC__ -#define MP_NOINLINE __attribute__((noinline)) -#endif - -// MSVC specifics -#ifdef _MSC_VER - -// Sanity check - -#if ( _MSC_VER < 1800 ) - #error Can only build with Visual Studio 2013 toolset -#endif - - -// CL specific overrides from mpconfig - -#define NORETURN __declspec(noreturn) -#define MP_NOINLINE __declspec(noinline) -#define MP_LIKELY(x) (x) -#define MP_UNLIKELY(x) (x) -#define MICROPY_PORT_CONSTANTS { "dummy", 0 } //can't have zero-sized array -#ifdef _WIN64 -#define MP_SSIZE_MAX _I64_MAX -#else -#define MP_SSIZE_MAX _I32_MAX -#endif - - -// CL specific definitions - -#define restrict -#define inline __inline -#define alignof(t) __alignof(t) -#define PATH_MAX MICROPY_ALLOC_PATH_MAX -#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) -#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) -#ifdef _WIN64 -#define SSIZE_MAX _I64_MAX -typedef __int64 ssize_t; -#else -#define SSIZE_MAX _I32_MAX -typedef int ssize_t; -#endif - - -// Put static/global variables in sections with a known name -// This used to be required for GC, not the case anymore but keep it as it makes the map file easier to inspect -// For this to work this header must be included by all sources, which is the case normally -#define MICROPY_PORT_DATASECTION "upydata" -#define MICROPY_PORT_BSSSECTION "upybss" -#pragma data_seg(MICROPY_PORT_DATASECTION) -#pragma bss_seg(MICROPY_PORT_BSSSECTION) - - -// System headers (needed e.g. for nlr.h) - -#include //for NULL -#include //for assert - -#endif diff --git a/windows/mpconfigport.mk b/windows/mpconfigport.mk deleted file mode 100644 index 87001d464..000000000 --- a/windows/mpconfigport.mk +++ /dev/null @@ -1,10 +0,0 @@ -# Enable/disable modules and 3rd-party libs to be included in interpreter - -# Build 32-bit binaries on a 64-bit host -MICROPY_FORCE_32BIT = 0 - -# Linking with GNU readline causes binary to be licensed under GPL -MICROPY_USE_READLINE = 1 - -# ffi module requires libffi (libffi-dev Debian package) -MICROPY_PY_FFI = 0 diff --git a/windows/msvc/common.props b/windows/msvc/common.props deleted file mode 100644 index 26ea78e7e..000000000 --- a/windows/msvc/common.props +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - $(PyOutDir) - $(PyIntDir) - $(PyBuildDir)copycookie$(Configuration)$(Platform) - - - - $(PyIncDirs);%(AdditionalIncludeDirectories) - _USE_MATH_DEFINES;_CRT_SECURE_NO_WARNINGS;_MBCS;%(PreprocessorDefinitions) - false - Level1 - false - true - false - - - true - true - - - - - $(PyWinDir)%(FileName)%(Extension) - - - - - - - - - - - - diff --git a/windows/msvc/debug.props b/windows/msvc/debug.props deleted file mode 100644 index fa1ca4fcb..000000000 --- a/windows/msvc/debug.props +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/windows/msvc/dirent.c b/windows/msvc/dirent.c deleted file mode 100644 index e050432a1..000000000 --- a/windows/msvc/dirent.c +++ /dev/null @@ -1,103 +0,0 @@ -/* -* This file is part of the MicroPython project, http://micropython.org/ -* -* The MIT License (MIT) -* -* Copyright (c) 2015 Damien P. George -* -* Permission is hereby granted, free of charge, to any person obtaining a copy -* of this software and associated documentation files (the "Software"), to deal -* in the Software without restriction, including without limitation the rights -* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -* copies of the Software, and to permit persons to whom the Software is -* furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in -* all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -* THE SOFTWARE. -*/ - -#include "dirent.h" -#include -#include - -typedef struct DIR { - HANDLE findHandle; - WIN32_FIND_DATA findData; - struct dirent result; -} DIR; - -DIR *opendir(const char *name) { - if (!name || !*name) { - errno = ENOENT; - return NULL; - } - - DIR *dir = malloc(sizeof(DIR)); - if (!dir) { - errno = ENOMEM; - return NULL; - } - dir->result.d_ino = 0; - dir->result.d_name = NULL; - dir->findHandle = INVALID_HANDLE_VALUE; - - const size_t nameLen = strlen(name); - char *path = malloc(nameLen + 3); // allocate enough for adding "/*" - if (!path) { - free(dir); - errno = ENOMEM; - return NULL; - } - strcpy(path, name); - - // assure path ends with wildcard - const char lastChar = path[nameLen - 1]; - if (lastChar != '*') { - const char *appendWC = (lastChar != '/' && lastChar != '\\') ? "/*" : "*"; - strcat(path, appendWC); - } - - // init - dir->findHandle = FindFirstFile(path, &dir->findData); - free(path); - if (dir->findHandle == INVALID_HANDLE_VALUE) { - free(dir); - errno = ENOENT; - return NULL; - } - return dir; -} - -int closedir(DIR *dir) { - if (dir) { - FindClose(dir->findHandle); - free(dir); - return 0; - } else { - errno = EBADF; - return -1; - } -} - -struct dirent *readdir(DIR *dir) { - if (!dir) { - errno = EBADF; - return NULL; - } - - // first pass d_name is NULL so use result from FindFirstFile in opendir, else use FindNextFile - if (!dir->result.d_name || FindNextFile(dir->findHandle, &dir->findData)) { - dir->result.d_name = dir->findData.cFileName; - return &dir->result; - } - - return NULL; -} diff --git a/windows/msvc/dirent.h b/windows/msvc/dirent.h deleted file mode 100644 index fca06785a..000000000 --- a/windows/msvc/dirent.h +++ /dev/null @@ -1,48 +0,0 @@ -/* -* This file is part of the MicroPython project, http://micropython.org/ -* -* The MIT License (MIT) -* -* Copyright (c) 2015 Damien P. George -* -* Permission is hereby granted, free of charge, to any person obtaining a copy -* of this software and associated documentation files (the "Software"), to deal -* in the Software without restriction, including without limitation the rights -* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -* copies of the Software, and to permit persons to whom the Software is -* furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in -* all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -* THE SOFTWARE. -*/ -#ifndef MICROPY_INCLUDED_WINDOWS_MSVC_DIRENT_H -#define MICROPY_INCLUDED_WINDOWS_MSVC_DIRENT_H - -// dirent.h implementation for msvc - -// for ino_t -#include - -// opaque DIR structure -typedef struct DIR DIR; - -// the dirent structure -// d_ino is always 0 - if ever needed use GetFileInformationByHandle -typedef struct dirent { - ino_t d_ino; - char *d_name; -} dirent; - -DIR *opendir(const char *name); -int closedir(DIR *dir); -struct dirent *readdir(DIR *dir); - -#endif // MICROPY_INCLUDED_WINDOWS_MSVC_DIRENT_H diff --git a/windows/msvc/genhdr.targets b/windows/msvc/genhdr.targets deleted file mode 100644 index cac3e3ddc..000000000 --- a/windows/msvc/genhdr.targets +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - - - - - - $(PyBuildDir)genhdr\ - $(PyBaseDir)py\ - $(PyBaseDir)unix\qstrdefsport.h - $(PySrcDir)qstrdefs.h - $(DestDir)qstrdefscollected.h - $(DestDir)qstrdefs.generated.h - python - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $([System.String]::new('%(FullPath)').Replace('$(PyBaseDir)', '$(DestDir)qstr\')) - - - $([System.IO.Path]::ChangeExtension('%(OutFile)', '.pp')) - $([System.IO.Path]::GetDirectoryName('%(OutFile)')) - - - True - - - True - - - - @(QstrDependencies->AnyHaveMetadataValue('Changed', 'True')) - @(PyQstrSourceFiles->AnyHaveMetadataValue('Changed', 'True')) - - - - - - - - - - - - $(QstrGen).tmp - - - - - - - - - $(DestDir)mpversion.h - $(DestFile).tmp - - - - - - - - - - - - - - - - - - diff --git a/windows/msvc/gettimeofday.c b/windows/msvc/gettimeofday.c deleted file mode 100644 index 5f816df70..000000000 --- a/windows/msvc/gettimeofday.c +++ /dev/null @@ -1,58 +0,0 @@ -/* -* This file is part of the MicroPython project, http://micropython.org/ -* -* The MIT License (MIT) -* -* Copyright (c) 2013, 2014 Damien P. George -* -* Permission is hereby granted, free of charge, to any person obtaining a copy -* of this software and associated documentation files (the "Software"), to deal -* in the Software without restriction, including without limitation the rights -* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -* copies of the Software, and to permit persons to whom the Software is -* furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in -* all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -* THE SOFTWARE. -*/ - -#include - -typedef union { - unsigned __int64 tm; // time in 100 nanoseconds interval - FILETIME ft; -} FT; - -int gettimeofday(struct timeval *tp, struct timezone *tz) { - if (tp == NULL) { - return 0; - } - - // UTC time - FT ft; - ZeroMemory(&ft, sizeof(ft)); - GetSystemTimeAsFileTime(&ft.ft); - - // to microseconds - ft.tm /= 10; - - // convert to unix format - // number of microseconds intervals between the 1st january 1601 and the 1st january 1970 (369 years + 89 leap days) - const unsigned __int64 deltaEpoch = 11644473600000000ull; - const unsigned __int64 microSecondsToSeconds = 1000000ull; - tp->tv_usec = ft.tm % microSecondsToSeconds; - tp->tv_sec = (ft.tm - deltaEpoch) / microSecondsToSeconds; - - // see man gettimeofday: timezone is deprecated and expected to be NULL - (void)tz; - - return 0; -} diff --git a/windows/msvc/paths.props b/windows/msvc/paths.props deleted file mode 100644 index 716698243..000000000 --- a/windows/msvc/paths.props +++ /dev/null @@ -1,45 +0,0 @@ - - - - True - - - - - $([System.IO.Path]::GetFullPath(`$(MSBuildThisFileDirectory)..\..`))\ - $(PyBaseDir)windows\ - $(PyWinDir)build\ - - - $(PyBaseDir);$(PyWinDir);$(PyBuildDir);$(PyWinDir)msvc - - - $(Platform) - $(Configuration) - - - $(PyBuildDir)$(PyConfiguration)$(PyPlatform)\ - $(PyOutDir)obj\ - - diff --git a/windows/msvc/release.props b/windows/msvc/release.props deleted file mode 100644 index ea0bf433d..000000000 --- a/windows/msvc/release.props +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - true - true - - - true - - - - diff --git a/windows/msvc/sources.props b/windows/msvc/sources.props deleted file mode 100644 index a97686cdc..000000000 --- a/windows/msvc/sources.props +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/windows/msvc/sys/time.h b/windows/msvc/sys/time.h deleted file mode 100644 index 7c95d409e..000000000 --- a/windows/msvc/sys/time.h +++ /dev/null @@ -1,32 +0,0 @@ -/* -* This file is part of the MicroPython project, http://micropython.org/ -* -* The MIT License (MIT) -* -* Copyright (c) 2013, 2014 Damien P. George -* -* Permission is hereby granted, free of charge, to any person obtaining a copy -* of this software and associated documentation files (the "Software"), to deal -* in the Software without restriction, including without limitation the rights -* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -* copies of the Software, and to permit persons to whom the Software is -* furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in -* all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -* THE SOFTWARE. -*/ -#ifndef MICROPY_INCLUDED_WINDOWS_MSVC_SYS_TIME_H -#define MICROPY_INCLUDED_WINDOWS_MSVC_SYS_TIME_H - -// Get the definitions for timeval etc -#include - -#endif // MICROPY_INCLUDED_WINDOWS_MSVC_SYS_TIME_H diff --git a/windows/msvc/unistd.h b/windows/msvc/unistd.h deleted file mode 100644 index 1a1629be4..000000000 --- a/windows/msvc/unistd.h +++ /dev/null @@ -1,44 +0,0 @@ -/* -* This file is part of the MicroPython project, http://micropython.org/ -* -* The MIT License (MIT) -* -* Copyright (c) 2013, 2014 Damien P. George -* -* Permission is hereby granted, free of charge, to any person obtaining a copy -* of this software and associated documentation files (the "Software"), to deal -* in the Software without restriction, including without limitation the rights -* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -* copies of the Software, and to permit persons to whom the Software is -* furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in -* all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -* THE SOFTWARE. -*/ -#ifndef MICROPY_INCLUDED_WINDOWS_MSVC_UNISTD_H -#define MICROPY_INCLUDED_WINDOWS_MSVC_UNISTD_H - -// There's no unistd.h, but this is the equivalent -#include - -#define F_OK 0 -#define W_OK 2 -#define R_OK 4 - -#define STDIN_FILENO 0 -#define STDOUT_FILENO 1 -#define STDERR_FILENO 2 - -#define SEEK_CUR 1 -#define SEEK_END 2 -#define SEEK_SET 0 - -#endif // MICROPY_INCLUDED_WINDOWS_MSVC_UNISTD_H diff --git a/windows/realpath.c b/windows/realpath.c deleted file mode 100644 index ac9adf812..000000000 --- a/windows/realpath.c +++ /dev/null @@ -1,64 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2013, 2014 Damien P. George - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#include -#include -#include - -// Make sure a path only has forward slashes. -char *to_unix_path(char *p) { - if (p != NULL) { - char *pp = p; - while (*pp != 0) { - if (*pp == '\\') - *pp = '/'; - ++pp; - } - } - return p; -} - -// Implement realpath() using _fullpath and make it use the same error codes as realpath() on unix. -// Also have it return a path with forward slashes only as some code relies on this, -// but _fullpath() returns backward slashes no matter what. -char *realpath(const char *path, char *resolved_path) { - char *ret = NULL; - if (path == NULL) { - errno = EINVAL; - } else if (access(path, R_OK) == 0) { - ret = resolved_path; - if (ret == NULL) - ret = malloc(_MAX_PATH); - if (ret == NULL) { - errno = ENOMEM; - } else { - ret = _fullpath(ret, path, _MAX_PATH); - if (ret == NULL) - errno = EIO; - } - } - return to_unix_path(ret); -} diff --git a/windows/realpath.h b/windows/realpath.h deleted file mode 100644 index 869fe80fa..000000000 --- a/windows/realpath.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2013, 2014 Damien P. George - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -#ifndef MICROPY_INCLUDED_WINDOWS_REALPATH_H -#define MICROPY_INCLUDED_WINDOWS_REALPATH_H - -extern char *realpath(const char *path, char *resolved_path); - -#endif // MICROPY_INCLUDED_WINDOWS_REALPATH_H diff --git a/windows/sleep.c b/windows/sleep.c deleted file mode 100644 index 6043ec7b7..000000000 --- a/windows/sleep.c +++ /dev/null @@ -1,76 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2013, 2014 Damien P. George - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#include -#include -#include - -HANDLE waitTimer = NULL; - -void init_sleep(void) { - waitTimer = CreateWaitableTimer(NULL, TRUE, NULL); -} - -void deinit_sleep(void) { - if (waitTimer != NULL) { - CloseHandle(waitTimer); - waitTimer = NULL; - } -} - -int usleep_impl(__int64 usec) { - if (waitTimer == NULL) { - errno = EAGAIN; - return -1; - } - if (usec < 0 || usec > LLONG_MAX / 10) { - errno = EINVAL; - return -1; - } - - LARGE_INTEGER ft; - ft.QuadPart = -10 * usec; // 100 nanosecond interval, negative value = relative time - if (SetWaitableTimer(waitTimer, &ft, 0, NULL, NULL, 0) == 0) { - errno = EINVAL; - return -1; - } - if (WaitForSingleObject(waitTimer, INFINITE) != WAIT_OBJECT_0) { - errno = EAGAIN; - return -1; - } - return 0; -} - -#ifdef _MSC_VER // mingw and the likes provide their own usleep() -int usleep(__int64 usec) { - return usleep_impl(usec); -} -#endif - -void msec_sleep(double msec) { - const double usec = msec * 1000.0; - usleep_impl(usec > (double)LLONG_MAX ? LLONG_MAX : (__int64)usec); -} diff --git a/windows/sleep.h b/windows/sleep.h deleted file mode 100644 index 430ec3a43..000000000 --- a/windows/sleep.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2015 Damien P. George - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -#ifndef MICROPY_INCLUDED_WINDOWS_SLEEP_H -#define MICROPY_INCLUDED_WINDOWS_SLEEP_H - -void init_sleep(void); -void deinit_sleep(void); -void msec_sleep(double msec); -#ifdef _MSC_VER -int usleep(__int64 usec); -#endif - -#endif // MICROPY_INCLUDED_WINDOWS_SLEEP_H diff --git a/windows/windows_mphal.c b/windows/windows_mphal.c deleted file mode 100644 index 153b04423..000000000 --- a/windows/windows_mphal.c +++ /dev/null @@ -1,229 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2015 Damien P. George - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - - -#include "py/mpstate.h" -#include "py/mphal.h" - -#include -#include -#include - -HANDLE std_in = NULL; -HANDLE con_out = NULL; -DWORD orig_mode = 0; - -STATIC void assure_stdin_handle() { - if (!std_in) { - std_in = GetStdHandle(STD_INPUT_HANDLE); - assert(std_in != INVALID_HANDLE_VALUE); - } -} - -STATIC void assure_conout_handle() { - if (!con_out) { - con_out = CreateFile("CONOUT$", GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, OPEN_EXISTING, 0, 0); - assert(con_out != INVALID_HANDLE_VALUE); - } -} - -void mp_hal_stdio_mode_raw(void) { - assure_stdin_handle(); - GetConsoleMode(std_in, &orig_mode); - DWORD mode = orig_mode; - mode &= ~ENABLE_ECHO_INPUT; - mode &= ~ENABLE_LINE_INPUT; - mode &= ~ENABLE_PROCESSED_INPUT; - SetConsoleMode(std_in, mode); -} - -void mp_hal_stdio_mode_orig(void) { - assure_stdin_handle(); - SetConsoleMode(std_in, orig_mode); -} - -// Handler to be installed by SetConsoleCtrlHandler, currently used only to handle Ctrl-C. -// This handler has to be installed just once (this has to be done elswhere in init code). -// Previous versions of the mp_hal code would install a handler whenever Ctrl-C input is -// allowed and remove the handler again when it is not. That is not necessary though (1), -// and it might introduce problems (2) because console notifications are delivered to the -// application in a separate thread. -// (1) mp_hal_set_interrupt_char effectively enables/disables processing of Ctrl-C via the -// ENABLE_PROCESSED_INPUT flag so in raw mode console_sighandler won't be called. -// (2) if mp_hal_set_interrupt_char would remove the handler while Ctrl-C was issued earlier, -// the thread created for handling it might not be running yet so we'd miss the notification. -BOOL WINAPI console_sighandler(DWORD evt) { - if (evt == CTRL_C_EVENT) { - if (MP_STATE_VM(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception))) { - // this is the second time we are called, so die straight away - exit(1); - } - mp_obj_exception_clear_traceback(MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception))); - MP_STATE_VM(mp_pending_exception) = MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception)); - return TRUE; - } - return FALSE; -} - -void mp_hal_set_interrupt_char(char c) { - assure_stdin_handle(); - if (c == CHAR_CTRL_C) { - DWORD mode; - GetConsoleMode(std_in, &mode); - mode |= ENABLE_PROCESSED_INPUT; - SetConsoleMode(std_in, mode); - } else { - DWORD mode; - GetConsoleMode(std_in, &mode); - mode &= ~ENABLE_PROCESSED_INPUT; - SetConsoleMode(std_in, mode); - } -} - -void mp_hal_move_cursor_back(uint pos) { - assure_conout_handle(); - CONSOLE_SCREEN_BUFFER_INFO info; - GetConsoleScreenBufferInfo(con_out, &info); - info.dwCursorPosition.X -= (short)pos; - if (info.dwCursorPosition.X < 0) { - info.dwCursorPosition.X = 0; - } - SetConsoleCursorPosition(con_out, info.dwCursorPosition); -} - -void mp_hal_erase_line_from_cursor(uint n_chars_to_erase) { - assure_conout_handle(); - CONSOLE_SCREEN_BUFFER_INFO info; - GetConsoleScreenBufferInfo(con_out, &info); - DWORD written; - FillConsoleOutputCharacter(con_out, ' ', n_chars_to_erase, info.dwCursorPosition, &written); - FillConsoleOutputAttribute(con_out, info.wAttributes, n_chars_to_erase, info.dwCursorPosition, &written); -} - -typedef struct item_t { - WORD vkey; - const char *seq; -} item_t; - -// map virtual key codes to VT100 escape sequences -STATIC item_t keyCodeMap[] = { - {VK_UP, "[A"}, - {VK_DOWN, "[B"}, - {VK_RIGHT, "[C"}, - {VK_LEFT, "[D"}, - {VK_HOME, "[H"}, - {VK_END, "[F"}, - {VK_DELETE, "[3~"}, - {0, ""} //sentinel -}; - -STATIC const char *cur_esc_seq = NULL; - -STATIC int esc_seq_process_vk(int vk) { - for (item_t *p = keyCodeMap; p->vkey != 0; ++p) { - if (p->vkey == vk) { - cur_esc_seq = p->seq; - return 27; // ESC, start of escape sequence - } - } - return 0; // nothing found -} - -STATIC int esc_seq_chr() { - if (cur_esc_seq) { - const char c = *cur_esc_seq++; - if (c) { - return c; - } - cur_esc_seq = NULL; - } - return 0; -} - -int mp_hal_stdin_rx_chr(void) { - // currently processing escape seq? - const int ret = esc_seq_chr(); - if (ret) { - return ret; - } - - // poll until key which we handle is pressed - assure_stdin_handle(); - DWORD num_read; - INPUT_RECORD rec; - for (;;) { - if (!ReadConsoleInput(std_in, &rec, 1, &num_read) || !num_read) { - return CHAR_CTRL_C; // EOF, ctrl-D - } - if (rec.EventType != KEY_EVENT || !rec.Event.KeyEvent.bKeyDown) { // only want key down events - continue; - } - const char c = rec.Event.KeyEvent.uChar.AsciiChar; - if (c) { // plain ascii char, return it - return c; - } - const int ret = esc_seq_process_vk(rec.Event.KeyEvent.wVirtualKeyCode); - if (ret) { - return ret; - } - } -} - -void mp_hal_stdout_tx_strn(const char *str, size_t len) { - write(1, str, len); -} - -void mp_hal_stdout_tx_strn_cooked(const char *str, size_t len) { - mp_hal_stdout_tx_strn(str, len); -} - -void mp_hal_stdout_tx_str(const char *str) { - mp_hal_stdout_tx_strn(str, strlen(str)); -} - -mp_uint_t mp_hal_ticks_ms(void) { - struct timeval tv; - gettimeofday(&tv, NULL); - return tv.tv_sec * 1000 + tv.tv_usec / 1000; -} - -mp_uint_t mp_hal_ticks_us(void) { - struct timeval tv; - gettimeofday(&tv, NULL); - return tv.tv_sec * 1000000 + tv.tv_usec; -} - -mp_uint_t mp_hal_ticks_cpu(void) { - LARGE_INTEGER value; - QueryPerformanceCounter(&value); -#ifdef _WIN64 - return value.QuadPart; -#else - return value.LowPart; -#endif -} diff --git a/windows/windows_mphal.h b/windows/windows_mphal.h deleted file mode 100644 index 5a93d4e18..000000000 --- a/windows/windows_mphal.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2015 Damien P. George - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#include "sleep.h" -#include "unix/mphalport.h" - -#define MICROPY_HAL_HAS_VT100 (0) - -void mp_hal_move_cursor_back(unsigned int pos); -void mp_hal_erase_line_from_cursor(unsigned int n_chars_to_erase); - -#undef mp_hal_ticks_cpu -mp_uint_t mp_hal_ticks_cpu(void); -- cgit v1.2.3