summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDamien Doligez <damien.doligez-inria.fr>2015-02-06 15:54:05 +0000
committerDamien Doligez <damien.doligez-inria.fr>2015-02-06 15:54:05 +0000
commit11bc5fe4bf05081ec7da05a6d407d39ceba727a4 (patch)
treeff913eea8d116e337dc209afb54e975072ec7325
parentc38fc546dcddd768f0affd645c8c526b0df254f4 (diff)
GPR#142: add a CAMLdrop macro for undoing CAMLparam*/CAMLlocal*
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@15814 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rw-r--r--Changes1
-rw-r--r--byterun/caml/memory.h12
2 files changed, 9 insertions, 4 deletions
diff --git a/Changes b/Changes
index bbb215732..0077b3de2 100644
--- a/Changes
+++ b/Changes
@@ -83,6 +83,7 @@ Features wishes:
- PR#6691: install .cmt[i] files for stdlib and compiler-libs
(David Sheets, request by Gabriel Radanne)
- PR#6742: remove duplicate virtual_flag information from Tstr_class
+- GPR#142: add a CAMLdrop macro for undoing CAMLparam*/CAMLlocal*
OCaml 4.02.2:
-------------
diff --git a/byterun/caml/memory.h b/byterun/caml/memory.h
index 2aa9c74eb..98a30cc1b 100644
--- a/byterun/caml/memory.h
+++ b/byterun/caml/memory.h
@@ -154,7 +154,9 @@ CAMLextern struct caml__roots_block *caml_local_roots; /* defined in roots.c */
Your function may raise an exception or return a [value] with the
[CAMLreturn] macro. Its argument is simply the [value] returned by
your function. Do NOT directly return a [value] with the [return]
- keyword. If your function returns void, use [CAMLreturn0].
+ keyword. If your function returns void, use [CAMLreturn0]. If you
+ un-register the local roots (i.e. undo the effects of the [CAMLparam*]
+ and [CAMLlocal] macros) without returning immediately, use [CAMLdrop].
All the identifiers beginning with "caml__" are reserved by OCaml.
Do not use them for anything (local or global variables, struct or
@@ -294,15 +296,17 @@ CAMLextern struct caml__roots_block *caml_local_roots; /* defined in roots.c */
CAMLxparamN (x, (size))
+#define CAMLdrop caml_local_roots = caml__frame
+
#define CAMLreturn0 do{ \
- caml_local_roots = caml__frame; \
+ CAMLdrop; \
return; \
}while (0)
#define CAMLreturnT(type, result) do{ \
type caml__temp_result = (result); \
- caml_local_roots = caml__frame; \
- return (caml__temp_result); \
+ CAMLdrop; \
+ return caml__temp_result; \
}while(0)
#define CAMLreturn(result) CAMLreturnT(value, result)