Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
115187f7
Commit
115187f7
authored
10 years ago
by
Damien George
Browse files
Options
Downloads
Patches
Plain Diff
unix: Allow to compile with float support disabled.
parent
afd6c8e1
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
unix/modffi.c
+8
-1
8 additions, 1 deletion
unix/modffi.c
with
8 additions
and
1 deletion
unix/modffi.c
+
8
−
1
View file @
115187f7
...
@@ -106,8 +106,10 @@ STATIC ffi_type *char2ffi_type(char c)
...
@@ -106,8 +106,10 @@ STATIC ffi_type *char2ffi_type(char c)
case
'I'
:
return
&
ffi_type_uint
;
case
'I'
:
return
&
ffi_type_uint
;
case
'l'
:
return
&
ffi_type_slong
;
case
'l'
:
return
&
ffi_type_slong
;
case
'L'
:
return
&
ffi_type_ulong
;
case
'L'
:
return
&
ffi_type_ulong
;
#if MICROPY_PY_BUILTINS_FLOAT
case
'f'
:
return
&
ffi_type_float
;
case
'f'
:
return
&
ffi_type_float
;
case
'd'
:
return
&
ffi_type_double
;
case
'd'
:
return
&
ffi_type_double
;
#endif
case
'C'
:
// (*)()
case
'C'
:
// (*)()
case
'P'
:
// const void*
case
'P'
:
// const void*
case
'p'
:
// void*
case
'p'
:
// void*
...
@@ -141,6 +143,7 @@ STATIC mp_obj_t return_ffi_value(ffi_arg val, char type)
...
@@ -141,6 +143,7 @@ STATIC mp_obj_t return_ffi_value(ffi_arg val, char type)
}
}
case
'v'
:
case
'v'
:
return
mp_const_none
;
return
mp_const_none
;
#if MICROPY_PY_BUILTINS_FLOAT
case
'f'
:
{
case
'f'
:
{
union
{
ffi_arg
ffi
;
float
flt
;
}
val_union
=
{
.
ffi
=
val
};
union
{
ffi_arg
ffi
;
float
flt
;
}
val_union
=
{
.
ffi
=
val
};
return
mp_obj_new_float
(
val_union
.
flt
);
return
mp_obj_new_float
(
val_union
.
flt
);
...
@@ -149,6 +152,7 @@ STATIC mp_obj_t return_ffi_value(ffi_arg val, char type)
...
@@ -149,6 +152,7 @@ STATIC mp_obj_t return_ffi_value(ffi_arg val, char type)
double
*
p
=
(
double
*
)
&
val
;
double
*
p
=
(
double
*
)
&
val
;
return
mp_obj_new_float
(
*
p
);
return
mp_obj_new_float
(
*
p
);
}
}
#endif
default:
default:
return
mp_obj_new_int
(
val
);
return
mp_obj_new_int
(
val
);
}
}
...
@@ -336,11 +340,14 @@ STATIC mp_obj_t ffifunc_call(mp_obj_t self_in, mp_uint_t n_args, mp_uint_t n_kw,
...
@@ -336,11 +340,14 @@ STATIC mp_obj_t ffifunc_call(mp_obj_t self_in, mp_uint_t n_args, mp_uint_t n_kw,
// pointer to a memory location of the correct size.
// pointer to a memory location of the correct size.
// TODO check if this needs to be done for other types which don't fit into
// TODO check if this needs to be done for other types which don't fit into
// ffi_arg.
// ffi_arg.
#if MICROPY_PY_BUILTINS_FLOAT
if
(
sizeof
(
ffi_arg
)
==
4
&&
self
->
rettype
==
'd'
)
{
if
(
sizeof
(
ffi_arg
)
==
4
&&
self
->
rettype
==
'd'
)
{
double
retval
;
double
retval
;
ffi_call
(
&
self
->
cif
,
self
->
func
,
&
retval
,
valueptrs
);
ffi_call
(
&
self
->
cif
,
self
->
func
,
&
retval
,
valueptrs
);
return
mp_obj_new_float
(
retval
);
return
mp_obj_new_float
(
retval
);
}
else
{
}
else
#endif
{
ffi_arg
retval
;
ffi_arg
retval
;
ffi_call
(
&
self
->
cif
,
self
->
func
,
&
retval
,
valueptrs
);
ffi_call
(
&
self
->
cif
,
self
->
func
,
&
retval
,
valueptrs
);
return
return_ffi_value
(
retval
,
self
->
rettype
);
return
return_ffi_value
(
retval
,
self
->
rettype
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment