Use external linkage for global async variables
This commit is contained in:
parent
74f5e9a2e8
commit
e536ec17d6
|
@ -13,12 +13,21 @@ let filter_async_objs cd =
|
||||||
| None -> false)
|
| None -> false)
|
||||||
cd.cd_objs
|
cd.cd_objs
|
||||||
|
|
||||||
let async_global_objs_defs cd =
|
let async_global_objs_vars cd =
|
||||||
List.map
|
List.map
|
||||||
(fun od ->
|
(fun od ->
|
||||||
let name = async_global_var_name od in
|
let name = async_global_var_name od in
|
||||||
let ty = Cty_id (qn_append od.o_class "_async") in
|
let ty = Cty_id (qn_append od.o_class "_async") in
|
||||||
Cvardef (name, ty))
|
name, ty)
|
||||||
(filter_async_objs cd)
|
(filter_async_objs cd)
|
||||||
|
|
||||||
|
let async_global_objs_defs cd =
|
||||||
|
List.map
|
||||||
|
(fun (name, ty) -> Cvardef (name, ty))
|
||||||
|
(async_global_objs_vars cd)
|
||||||
|
|
||||||
|
let async_global_objs_decls cd =
|
||||||
|
List.map
|
||||||
|
(fun (name, ty) -> Cdecl_extern (name, ty))
|
||||||
|
(async_global_objs_vars cd)
|
||||||
|
|
||||||
|
|
|
@ -143,6 +143,7 @@ type cdecl =
|
||||||
(** C function declaration. *)
|
(** C function declaration. *)
|
||||||
| Cdecl_constant of string * cty * cexpr
|
| Cdecl_constant of string * cty * cexpr
|
||||||
(** C constant declaration (alias, name)*)
|
(** C constant declaration (alias, name)*)
|
||||||
|
| Cdecl_extern of string * cty
|
||||||
|
|
||||||
(** C function definitions *)
|
(** C function definitions *)
|
||||||
type cfundef = {
|
type cfundef = {
|
||||||
|
@ -353,6 +354,9 @@ let pp_cdecl fmt cdecl = match cdecl with
|
||||||
| Cdecl_constant (n, cty, ce) ->
|
| Cdecl_constant (n, cty, ce) ->
|
||||||
fprintf fmt "@[<v>static const %a = %a;@ @]@\n"
|
fprintf fmt "@[<v>static const %a = %a;@ @]@\n"
|
||||||
pp_vardecl (n, cty) pp_cconst_expr ce
|
pp_vardecl (n, cty) pp_cconst_expr ce
|
||||||
|
| Cdecl_extern (n, cty) ->
|
||||||
|
fprintf fmt "@[<v>extern %a;@ @]@\n"
|
||||||
|
pp_vardecl (n, cty)
|
||||||
|
|
||||||
let pp_cdef fmt cdef = match cdef with
|
let pp_cdef fmt cdef = match cdef with
|
||||||
| Cfundef cfd ->
|
| Cfundef cfd ->
|
||||||
|
|
|
@ -947,6 +947,7 @@ let cdefs_and_cdecls_of_class_def cd =
|
||||||
let out_struct_decl = out_decl_of_class_def cd in
|
let out_struct_decl = out_decl_of_class_def cd in
|
||||||
let async_struct_decl = async_decl_of_class_def cd in
|
let async_struct_decl = async_decl_of_class_def cd in
|
||||||
let objs = async_global_objs_defs cd in
|
let objs = async_global_objs_defs cd in
|
||||||
|
let objs_decls = async_global_objs_decls cd in
|
||||||
let step = fun_def_of_step_fun cd.cd_name cd.cd_objs cd.cd_mems
|
let step = fun_def_of_step_fun cd.cd_name cd.cd_objs cd.cd_mems
|
||||||
cd.cd_objs step_m in
|
cd.cd_objs step_m in
|
||||||
(* TODO(Arduino): let the user choose the backend they want *)
|
(* TODO(Arduino): let the user choose the backend they want *)
|
||||||
|
@ -973,7 +974,7 @@ let cdefs_and_cdecls_of_class_def cd =
|
||||||
let decls = List.map cdecl_of_cfundef defs in
|
let decls = List.map cdecl_of_cfundef defs in
|
||||||
|
|
||||||
memory_struct_decl @ in_struct_decl @ out_struct_decl @ async_struct_decl
|
memory_struct_decl @ in_struct_decl @ out_struct_decl @ async_struct_decl
|
||||||
@ decls, objs @ defs
|
@ objs_decls @ decls, objs @ defs
|
||||||
|
|
||||||
(** {2 Type translation} *)
|
(** {2 Type translation} *)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue