summaryrefslogtreecommitdiffstatshomepage
path: root/py
diff options
context:
space:
mode:
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>2014-05-09 00:03:42 +0300
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2014-05-09 00:03:42 +0300
commit62b5f42d8174e49bc219e5231d4fc9503ece4131 (patch)
tree77f04b1a2af0c4667e5ef3194b2717a7a0047f67 /py
parentffae48d7507d398806bd935b054b7ca19bc01161 (diff)
parent01d6be4d512118d39ef52f79ca9ddddd2bba3f32 (diff)
downloadmicropython-62b5f42d8174e49bc219e5231d4fc9503ece4131.tar.gz
micropython-62b5f42d8174e49bc219e5231d4fc9503ece4131.zip
Merge pull request #568 from stinos/windows-msvc-port
Windows MS Visual C port
Diffstat (limited to 'py')
-rw-r--r--py/mpconfig.h2
-rw-r--r--py/mpz.c7
-rw-r--r--py/objint.c2
-rw-r--r--py/runtime.c6
4 files changed, 12 insertions, 5 deletions
diff --git a/py/mpconfig.h b/py/mpconfig.h
index 275147886c..119859a3a4 100644
--- a/py/mpconfig.h
+++ b/py/mpconfig.h
@@ -317,4 +317,6 @@ typedef double mp_float_t;
#endif //INT_FMT
// Modifier for function which doesn't return
+#ifndef NORETURN
#define NORETURN __attribute__((noreturn))
+#endif
diff --git a/py/mpz.c b/py/mpz.c
index d6eca30685..8eed283f04 100644
--- a/py/mpz.c
+++ b/py/mpz.c
@@ -1092,8 +1092,11 @@ mpz_t *mpz_gcd(const mpz_t *z1, const mpz_t *z2) {
*/
mpz_t *mpz_lcm(const mpz_t *z1, const mpz_t *z2)
{
- if (z1->len == 0 || z2->len == 0)
- return mpz_zero();
+ // braces below are required for compilation to succeed with CL, see bug report
+ // https://connect.microsoft.com/VisualStudio/feedback/details/864169/compilation-error-when-braces-are-left-out-of-single-line-if-statement
+ if (z1->len == 0 || z2->len == 0) {
+ return mpz_zero();
+ }
mpz_t *gcd = mpz_gcd(z1, z2);
mpz_t *quo = mpz_zero();
diff --git a/py/objint.c b/py/objint.c
index c8bcb6080c..73b4c5d0be 100644
--- a/py/objint.c
+++ b/py/objint.c
@@ -303,7 +303,7 @@ STATIC mp_obj_t int_from_bytes(uint n_args, const mp_obj_t *args) {
// convert the bytes to an integer
machine_uint_t value = 0;
- for (const byte* buf = bufinfo.buf + bufinfo.len - 1; buf >= (byte*)bufinfo.buf; buf--) {
+ for (const byte* buf = (const byte*)bufinfo.buf + bufinfo.len - 1; buf >= (byte*)bufinfo.buf; buf--) {
value = (value << 8) | *buf;
}
diff --git a/py/runtime.c b/py/runtime.c
index a5a5bc5a4a..7a701fec57 100644
--- a/py/runtime.c
+++ b/py/runtime.c
@@ -27,6 +27,7 @@
#include <stdio.h>
#include <string.h>
#include <assert.h>
+#include <alloca.h>
#include "mpconfig.h"
#include "nlr.h"
@@ -1074,11 +1075,12 @@ import_error:
uint pkg_name_len;
const char *pkg_name = mp_obj_str_get_data(dest[0], &pkg_name_len);
- char dot_name[pkg_name_len + 1 + qstr_len(name)];
+ const uint dot_name_len = pkg_name_len + 1 + qstr_len(name);
+ char *dot_name = alloca(dot_name_len);
memcpy(dot_name, pkg_name, pkg_name_len);
dot_name[pkg_name_len] = '.';
memcpy(dot_name + pkg_name_len + 1, qstr_str(name), qstr_len(name));
- qstr dot_name_q = qstr_from_strn(dot_name, sizeof(dot_name));
+ qstr dot_name_q = qstr_from_strn(dot_name, dot_name_len);
mp_obj_t args[5];
args[0] = MP_OBJ_NEW_QSTR(dot_name_q);