Wykres commitów

47 Commity (062bd81814029cfc7029c55d98dc6e742cb33990)

Autor SHA1 Wiadomość Data
Vicente Olivert Riera 587914169c unix/modffi.c: cast first to intptr_t when casting from/to pointer
This fixes errors like these ones:

modffi.c: In function 'return_ffi_value':
modffi.c:143:29: error: cast to pointer from integer of different size
[-Werror=int-to-pointer-cast]
             const char *s = (const char *)val;
                             ^
modffi.c:162:20: error: cast to pointer from integer of different size
[-Werror=int-to-pointer-cast]
             return (mp_obj_t)val;
                    ^
modffi.c: In function 'ffifunc_call':
modffi.c:358:25: error: cast from pointer to integer of different size
[-Werror=pointer-to-int-cast]
             values[i] = (ffi_arg)a;
                         ^
modffi.c:373:25: error: cast from pointer to integer of different size
[-Werror=pointer-to-int-cast]
             values[i] = (ffi_arg)s;
                         ^
modffi.c:381:25: error: cast from pointer to integer of different size
[-Werror=pointer-to-int-cast]
             values[i] = (ffi_arg)bufinfo.buf;
                         ^
modffi.c:384:25: error: cast from pointer to integer of different size
[-Werror=pointer-to-int-cast]
             values[i] = (ffi_arg)p->func;
                         ^

These errors can be highlighted when building micropython from MIPS64
n32 because ffi_arg is 64-bit wide and the pointers on MIPS64 n32 are
32-bit wide, so it's trying to case an integer to a pointer (or
vice-versa) of a different size. We should cast first the pointer (or the
integer) to a pointer sized integer (intptr_t) to fix that problem.

Signed-off-by: Vicente Olivert Riera <Vincent.Riera@imgtec.com>
2015-09-22 18:54:31 -07:00
Paul Sokolovsky 696eee9475 modffi: dlsym() doesn't set errno, so use ENOENT for OSError.
This may be a bit confusing, as ENOENT is often rendered as "No such
file or directory", but any other code would be only more confusing.
2015-08-31 00:20:08 +03:00
Damien George a9afcb159a unix/modffi.c: get_buffer is allowed to return NULL if len=0.
This is consistent with the logic in mp_get_buffer, and the code here is
an inlined version of that function.
2015-05-01 21:34:08 +01:00
Damien George 6bbbb1ab41 unix/modffi: Support passing float/double args. 2015-04-28 19:40:34 +01:00
Damien George 7f9d1d6ab9 py: Overhaul and simplify printf/pfenv mechanism.
Previous to this patch the printing mechanism was a bit of a tangled
mess.  This patch attempts to consolidate printing into one interface.

All (non-debug) printing now uses the mp_print* family of functions,
mainly mp_printf.  All these functions take an mp_print_t structure as
their first argument, and this structure defines the printing backend
through the "print_strn" function of said structure.

Printing from the uPy core can reach the platform-defined print code via
two paths: either through mp_sys_stdout_obj (defined pert port) in
conjunction with mp_stream_write; or through the mp_plat_print structure
which uses the MP_PLAT_PRINT_STRN macro to define how string are printed
on the platform.  The former is only used when MICROPY_PY_IO is defined.

With this new scheme printing is generally more efficient (less layers
to go through, less arguments to pass), and, given an mp_print_t*
structure, one can call mp_print_str for efficiency instead of
mp_printf("%s", ...).  Code size is also reduced by around 200 bytes on
Thumb2 archs.
2015-04-16 14:30:16 +00:00
Paul Sokolovsky bbaf68f2cb modffi: Implement 'O' type handling for func arguments. 2015-02-25 23:38:22 +02:00
Paul Sokolovsky 99bcaa2fb6 modffi: Add toplevel func() function to create a function by pointer. 2015-02-11 07:21:03 +08:00
Paul Sokolovsky 8775caf9f1 modffi: Add .addr() method to just get symbol address. 2015-02-06 00:19:43 +02:00
Paul Sokolovsky 31c1f1300e modffi: 's' (string) return type: handle NULL properly (return None). 2015-01-25 01:36:14 +02:00
Paul Sokolovsky 2e526ff1a1 modffi: Support return values of mp_obj_t type. 2015-01-22 01:09:17 +02:00
Paul Sokolovsky 0ab3fc3805 modffi: Support open own executable using open(None). 2015-01-21 00:38:06 +02:00
Damien George ff8dd3f486 py, unix: Allow to compile with -Wunused-parameter.
See issue #699.
2015-01-20 12:47:20 +00:00
Damien George 963a5a3e82 py, unix: Allow to compile with -Wsign-compare.
See issue #699.
2015-01-16 17:47:07 +00:00
Damien George 115187f7ce unix: Allow to compile with float support disabled. 2015-01-08 15:41:11 +00:00
Damien George 6d7e47087f unix: Prefix includes with py/; remove need for -I../py. 2015-01-01 20:40:19 +00:00
Paul Sokolovsky 0078561303 modffi: Support void (None) return value for Python callback functions. 2014-12-16 00:28:12 +02:00
Paul Sokolovsky b62371e8fb modffi: 64-bit cleanness (fixes actual bug in callback arg handling). 2014-12-15 02:18:49 +02:00
Damien George 969a6b37bf py: Make functions static where appropriate. 2014-12-10 22:08:14 +00:00
Damien George be6d8be91e py: Rename mp_obj_int_get to mp_obj_int_get_truncated; fix struct.pack.
mp_obj_int_get_truncated is used as a "fast path" int accessor that
doesn't check for overflow and returns the int truncated to the machine
word size, ie mp_int_t.

Use mp_obj_int_get_truncated to fix struct.pack when packing maximum word
sized values.

Addresses issues #779 and #998.
2014-12-05 23:13:52 +00:00
Damien George 3b603f29ec Use MP_DEFINE_CONST_DICT macro to define module dicts.
This is just a clean-up of the code.  Generated code is exactly the
same.
2014-11-29 14:39:27 +00:00
Damien George 91fe0d4880 unix: Fix modffi to be able to return double on x86 machines. 2014-09-06 23:04:42 +00:00
Damien George 17598d49e1 unix: Don't use -Wno-error=cpp or #warning; fix strict alias warning.
For the sake of older versions of gcc (and other compilers), don't use
the #warning CPP directive, nor the -Wno-error=cpp option.

Also, fix a strict alias warning in modffi.c for older compilers, and
add a test for ffi module.

Addresses issue #847.
2014-09-06 17:46:52 +01:00
Damien George d182b98a37 py: Change all uint to mp_uint_t in obj.h.
Part of code cleanup, working towards resolving issue #50.
2014-08-30 14:19:41 +01:00
Damien George ecc88e949c Change some parts of the core API to use mp_uint_t instead of uint/int.
Addressing issue #50, still some way to go yet.
2014-08-30 00:35:11 +01:00
Damien George bb4c6f35c6 py: Make MP_OBJ_NEW_SMALL_INT cast arg to mp_int_t itself.
Addresses issue #724.
2014-07-31 10:49:14 +01:00
Damien George 40f3c02682 Rename machine_(u)int_t to mp_(u)int_t.
See discussion in issue #50.
2014-07-03 13:25:24 +01:00
Paul Sokolovsky e95b6b5e07 modffi: Add special 'C' code for passing a callback function pointer. 2014-07-01 02:05:34 +03:00
Paul Sokolovsky a23475979b modffi: Support short types. 2014-06-29 15:48:21 +03:00
Emmanuel Blot f6932d6506 Prefix ARRAY_SIZE with micropython prefix MP_ 2014-06-19 18:54:34 +02:00
Damien George 2617eebf2f Change const byte* to const char* where sensible.
This removes need for some casts (at least, more than it adds need
for new casts!).
2014-05-25 22:27:57 +01:00
Paul Sokolovsky da9f0924ef py, unix: Add copyright for modules I worked closely on. 2014-05-13 18:41:25 +03:00
Damien George 04b9147e15 Add license header to (almost) all files.
Blanket wide to all .c and .h files.  Some files originating from ST are
difficult to deal with (license wise) so it was left out of those.

Also merged modpyb.h, modos.h, modstm.h and modtime.h in stmhal/.
2014-05-03 23:27:38 +01:00
Paul Sokolovsky 9b71b16a94 unix,stmhal: Make "mpconfig.h" be first included, as other headers depend on it. 2014-05-02 18:08:16 +03:00
Damien George 6d3c5e4301 Add ARRAY_SIZE macro, and use it where possible. 2014-04-26 10:47:29 +01:00
Paul Sokolovsky fa6f0506c1 unix: Workaround MP_OBJ_NEW_SMALL_INT() 64-bit issues. 2014-04-22 00:16:46 +03:00
Paul Sokolovsky acb13886fc unix: OSError's args[0] should be errno numeric value.
Well, Python3 also defines an attribute for that, but that's bloat.
2014-04-22 00:02:51 +03:00
Paul Sokolovsky b418b6fb0d modffi: Don't use OSError for clearly unrelated errors. 2014-04-22 00:02:51 +03:00
Paul Sokolovsky 88972b0d94 modffi: Describe typecodes where they differ from used by struct module.
Exact behavior of typecodes may be not yet enforced.
2014-04-22 00:02:51 +03:00
Paul Sokolovsky 9ae0912496 modffi: Update for MP_OBJ_STOP_ITERATION refactor. 2014-04-19 20:05:47 +03:00
Paul Sokolovsky 752d2080b7 modffi: Mark 'p' type spec deprecated, replace with 'P'.
'p' in struct module is "pascal string". 'P' is void*.
2014-04-19 03:18:14 +03:00
Damien George 738bdeb73a unix: Update to use new buffer protocol interface with typecode. 2014-04-18 22:31:24 +01:00
Paul Sokolovsky 4abaa1b12b unix modffi: Convert to static module structures. 2014-04-18 00:05:27 +03:00
Paul Sokolovsky f200c30d53 modffi: Support float types. 2014-04-17 03:38:45 +03:00
Paul Sokolovsky 263853ef84 modffi: Update for latest binary API refactors. 2014-04-11 05:17:41 +03:00
Paul Sokolovsky f898a95cba unix modffi: Support any object implementing buffer protocol as a native arg. 2014-04-08 19:08:34 +03:00
Damien George ea13f407a3 py: Change nlr_jump to nlr_raise, to aid in debugging.
This does not affect code size or performance when debugging turned off.

To address issue #420.
2014-04-05 18:32:08 +01:00
Paul Sokolovsky c39368427c unix: Rename module sources per latest naming conventions (mod*.c). 2014-04-04 20:34:10 +03:00