Skip to content
Snippets Groups Projects
Commit 14b929f1 authored by Damien George's avatar Damien George
Browse files

Merge branch 'master' of github.com:msiemens/micropython into msiemens-master

parents 62ad189a 242856cf
No related branches found
No related tags found
No related merge requests found
#include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <assert.h> #include <assert.h>
#include <string.h> #include <string.h>
......
...@@ -5,9 +5,15 @@ ...@@ -5,9 +5,15 @@
.text .text
/* uint nlr_push(4(%esp)=nlr_buf_t *nlr) */ /* uint nlr_push(4(%esp)=nlr_buf_t *nlr) */
#ifdef _WIN32
.globl _nlr_push
.def _nlr_push; .scl 2; .type 32; .endef
_nlr_push:
#else
.globl nlr_push .globl nlr_push
.type nlr_push, @function .type nlr_push, @function
nlr_push: nlr_push:
#endif
mov 4(%esp), %edx # load nlr_buf mov 4(%esp), %edx # load nlr_buf
mov (%esp), %eax # load return %ip mov (%esp), %eax # load return %ip
mov %eax, 8(%edx) # store %ip into nlr_buf+8 mov %eax, 8(%edx) # store %ip into nlr_buf+8
...@@ -21,22 +27,38 @@ nlr_push: ...@@ -21,22 +27,38 @@ nlr_push:
mov %edx, nlr_top # stor new nlr_buf (to make linked list) mov %edx, nlr_top # stor new nlr_buf (to make linked list)
xor %eax, %eax # return 0, normal return xor %eax, %eax # return 0, normal return
ret # return ret # return
#ifndef _WIN32
.size nlr_push, .-nlr_push .size nlr_push, .-nlr_push
#endif
/* void nlr_pop() */ /* void nlr_pop() */
#ifdef _WIN32
.globl _nlr_pop
.def _nlr_pop; .scl 2; .type 32; .endef
_nlr_pop:
#else
.globl nlr_pop .globl nlr_pop
.type nlr_pop, @function .type nlr_pop, @function
nlr_pop: nlr_pop:
#endif
mov nlr_top, %eax # load nlr_top mov nlr_top, %eax # load nlr_top
mov (%eax), %eax # load prev nlr_buf mov (%eax), %eax # load prev nlr_buf
mov %eax, nlr_top # store nlr_top (to unlink list) mov %eax, nlr_top # store nlr_top (to unlink list)
ret # return ret # return
#ifndef _WIN32
.size nlr_pop, .-nlr_pop .size nlr_pop, .-nlr_pop
#endif
/* void nlr_jump(4(%esp)=uint val) */ /* void nlr_jump(4(%esp)=uint val) */
#ifdef _WIN32
.globl _nlr_jump
.def _nlr_jump; .scl 2; .type 32; .endef
_nlr_jump:
#else
.globl nlr_jump .globl nlr_jump
.type nlr_jump, @function .type nlr_jump, @function
nlr_jump: nlr_jump:
#endif
mov nlr_top, %edx # load nlr_top mov nlr_top, %edx # load nlr_top
mov 4(%esp), %eax # load return value mov 4(%esp), %eax # load return value
mov %eax, 4(%edx) # store return value mov %eax, 4(%edx) # store return value
...@@ -52,8 +74,13 @@ nlr_jump: ...@@ -52,8 +74,13 @@ nlr_jump:
xor %eax, %eax # clear return register xor %eax, %eax # clear return register
inc %al # increase to make 1, non-local return inc %al # increase to make 1, non-local return
ret # return ret # return
#ifndef _WIN32
.size nlr_jump, .-nlr_jump .size nlr_jump, .-nlr_jump
#endif
#ifndef _WIN32
.local nlr_top .local nlr_top
.comm nlr_top,4,4
#endif #endif
.comm nlr_top,4,4
#endif /* __i386__ */
#!/usr/bin/env bash #! /usr/bin/env python3.3
RM="/bin/rm -f" import os
CPYTHON3=python3.3 import subprocess
MP_PY=../unix/micropython import sys
from glob import glob
numtests=0
numtestcases=0 if os.name == 'nt':
numpassed=0 CPYTHON3 = 'python3.3.exe'
numfailed=0 MP_PY = '../windows/micropython.exe'
namefailed= else:
CPYTHON3 = 'python3.3'
if [ $# -eq 0 ] MP_PY = '../unix/micropython'
then
tests="basics/*.py io/*.py"
else test_count = 0
tests="$@" testcase_count = 0
fi passed_count = 0
failed_tests = []
for infile in $tests tests = []
do
basename=`basename $infile .py` if not sys.argv[1:]:
outfile=${basename}.out tests = glob('basics/*.py') + glob('io/*.py')
expfile=${basename}.exp else:
tests = sys.argv[1:]
$CPYTHON3 -B $infile > $expfile
$MP_PY $infile > $outfile for test_file in tests:
((numtestcases = numtestcases + $(cat $expfile | wc -l))) test_name = os.path.splitext(os.path.basename(test_file))[0]
diff --brief $expfile $outfile > /dev/null output_expected = subprocess.check_output([CPYTHON3, '-B', test_file])
output_mypy = subprocess.check_output([MP_PY, test_file])
if [ $? -eq 0 ]
then testcase_count += len(output_expected.splitlines())
echo "pass $infile"
$RM $outfile if output_expected != output_mypy:
$RM $expfile print("pass ", test_file)
((numpassed=numpassed + 1)) passed_count += 1
else else:
echo "FAIL $infile" print("FAIL ", test_file)
((numfailed=numfailed + 1)) failed_tests.append(test_name)
namefailed="$namefailed $basename"
fi test_count += 1
((numtests=numtests + 1)) print("{} tests performed ({} individual testcases)".format(test_count,
done testcase_count))
print("{} tests passed".format(passed_count))
echo "$numtests tests performed ($numtestcases individual testcases)"
echo "$numpassed tests passed" if len(failed_tests) > 0:
if [[ $numfailed != 0 ]] print("{} tests failed: {}".format(len(failed_tests),
then ' '.join(failed_tests)))
echo "$numfailed tests failed -$namefailed" sys.exit(1)
exit 1
else
exit 0
fi
include ../py/mkenv.mk
# define main target
PROG = micropython.exe
# qstr definitions (must come before including py.mk)
QSTR_DEFS = qstrdefsport.h
# include py core make definitions
include ../py/py.mk
# compiler settings
CFLAGS = -I. -I$(PY_SRC) -Wall -Werror -ansi -std=gnu99 -DUNIX
LDFLAGS = -lm
# Debugging/Optimization
ifdef DEBUG
CFLAGS += -O0 -g
else
CFLAGS += -Os #-DNDEBUG
endif
# source files
SRC_C = \
main.c \
file.c \
OBJ = $(PY_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
LIB = -lreadline
LIB += -lws2_32
LIB += -lmman
# the following is needed for BSD
#LIB += -ltermcap
include ../py/mkrules.mk
#include <stdio.h>
#include "../unix/file.c"
\ No newline at end of file
#include "../unix/main.c"
void rawsocket_init() {
// Do nothing here
}
\ No newline at end of file
// options to control how Micro Python is built
// Linking with GNU readline causes binary to be licensed under GPL
#ifndef MICROPY_USE_READLINE
#define MICROPY_USE_READLINE (1)
#endif
#define MICROPY_EMIT_X64 (1)
#define MICROPY_EMIT_THUMB (0)
#define MICROPY_EMIT_INLINE_THUMB (0)
#define MICROPY_MEM_STATS (1)
#define MICROPY_DEBUG_PRINTERS (1)
#define MICROPY_ENABLE_REPL_HELPERS (1)
#define MICROPY_ENABLE_LEXER_UNIX (1)
#define MICROPY_ENABLE_FLOAT (1)
#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_LONGLONG)
// type definitions for the specific machine
#ifdef __LP64__
typedef long machine_int_t; // must be pointer size
typedef unsigned long machine_uint_t; // must be pointer size
#else
// These are definitions for machines where sizeof(int) == sizeof(void*),
// regardless for actual size.
typedef int machine_int_t; // must be pointer size
typedef unsigned int machine_uint_t; // must be pointer size
#endif
#define BYTES_PER_WORD sizeof(machine_int_t)
typedef void *machine_ptr_t; // must be of pointer size
typedef const void *machine_const_ptr_t; // must be of pointer size
typedef double machine_float_t;
machine_float_t machine_sqrt(machine_float_t x);
// qstrs specific to this port
Q(sys)
Q(argv)
Q(open)
Q(stdin)
Q(stdout)
Q(stderr)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment