diff options
| author | stijn | 2015-01-08 10:32:45 +0100 |
|---|---|---|
| committer | stijn | 2015-01-08 15:29:44 +0100 |
| commit | afd6c8e1d2a2c24595194879481987cec3b57f8a (patch) | |
| tree | 918ec7c40ee16d00c7f085a853b6f6e2e1010247 /windows | |
| parent | 181bfb6db2a089442e5b3d38d68b1236b8aa0eb0 (diff) | |
Remove obsolete bss-related code/build features
GC for unix/windows builds doesn't make use of the bss section anymore,
so we do not need the (sometimes complicated) build features and code related to it
Diffstat (limited to 'windows')
| -rw-r--r-- | windows/Makefile | 1 | ||||
| -rw-r--r-- | windows/bss.c | 71 | ||||
| -rw-r--r-- | windows/init.c | 3 | ||||
| -rw-r--r-- | windows/mpconfigport.h | 8 |
4 files changed, 2 insertions, 81 deletions
diff --git a/windows/Makefile b/windows/Makefile index 5d5c7db79..342a2e4bc 100644 --- a/windows/Makefile +++ b/windows/Makefile @@ -37,7 +37,6 @@ SRC_C = \ realpath.c \ init.c \ sleep.c \ - bss.c \ OBJ = $(PY_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o)) diff --git a/windows/bss.c b/windows/bss.c deleted file mode 100644 index 58509024f..000000000 --- a/windows/bss.c +++ /dev/null @@ -1,71 +0,0 @@ -/* -* This file is part of the Micro Python 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 "py/nlr.h" -#include "py/obj.h" -#include <windows.h> - -IMAGE_NT_HEADERS *header_from_memory(const char *module) { - BYTE *base_addr = (BYTE*)GetModuleHandleA(module); - IMAGE_DOS_HEADER *dos_header = (IMAGE_DOS_HEADER*)base_addr; - return (IMAGE_NT_HEADERS*)(base_addr + dos_header->e_lfanew); -} - -IMAGE_SECTION_HEADER *find_section(IMAGE_NT_HEADERS *nt_header, const char *name) { - int i; - IMAGE_SECTION_HEADER *section = IMAGE_FIRST_SECTION(nt_header); - for (i = 0; i < nt_header->FileHeader.NumberOfSections; ++i) { - if (strcmp((const char *)section->Name, name) == 0) { - return section; - } - ++section; - } - return NULL; -} - -void section_boundaries(IMAGE_NT_HEADERS *nt_header, IMAGE_SECTION_HEADER *section, char **start, char **end) { - if (section == NULL) { - nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "Could not lookup section boundaries")); - } - *start = (char*)(nt_header->OptionalHeader.ImageBase + section->VirtualAddress); - *end = *start + section->Misc.VirtualSize; -} - -void section_boundaries_from_module(const char *module, const char *section, char **start, char **end) { - IMAGE_NT_HEADERS *nt_header = header_from_memory(module); - IMAGE_SECTION_HEADER *dsection = find_section(nt_header, section); - section_boundaries(nt_header, dsection, start, end); -} - -char *bss_start = 0; -char *bss_end = 0; - -//MSVC has no __bss_start and _end but we can get accurate section info from the PE header. -//The standard .bss section is appended to the standard .data section however so it cannot -//be looked up by name. To deal with that we put all uPy static variables in a named section. -void getbss() { - section_boundaries_from_module(NULL, MICROPY_PORT_BSSSECTION, &bss_start, &bss_end); -} diff --git a/windows/init.c b/windows/init.c index 57f349ef8..a370c464e 100644 --- a/windows/init.c +++ b/windows/init.c @@ -28,12 +28,9 @@ #include <stdio.h> #include <windows.h> -extern void getbss(); - HANDLE hSleepEvent = NULL; void init() { - getbss(); hSleepEvent = CreateEvent(NULL, TRUE, FALSE, FALSE); #ifdef __MINGW32__ putenv("PRINTF_EXPONENT_DIGITS=2"); diff --git a/windows/mpconfigport.h b/windows/mpconfigport.h index 939010343..aede68e21 100644 --- a/windows/mpconfigport.h +++ b/windows/mpconfigport.h @@ -166,7 +166,8 @@ void msec_sleep(double msec); #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) -// Put static/global variables in sections with a known name we can lookup for the GC +// 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" @@ -183,8 +184,3 @@ void msec_sleep(double msec); int snprintf(char *dest, size_t count, const char *format, ...); #endif - -// MingW specifics -#ifdef __MINGW32__ -#define MICROPY_PORT_BSSSECTION ".bss" -#endif |
