+perl4caml_hv_iterinit (value hvv)
+{
+ CAMLparam1 (hvv);
+ HV *hv = Hv_val (hvv);
+ int i = hv_iterinit (hv);
+ CAMLreturn (caml_copy_int32 (i));
+}
+
+CAMLprim value
+perl4caml_hv_iternext (value hvv)
+{
+ CAMLparam1 (hvv);
+ CAMLlocal1 (hev);
+ HV *hv = Hv_val (hvv);
+ HE *he = hv_iternext (hv);
+ if (he == NULL) caml_raise_not_found ();
+ hev = Val_he (he);
+ CAMLreturn (hev);
+}
+
+CAMLprim value
+perl4caml_hv_iterkey (value hev)
+{
+ CAMLparam1 (hev);
+ CAMLlocal1 (strv);
+ HE *he = He_val (hev);
+ I32 len;
+ char *str = hv_iterkey (he, &len);
+ strv = caml_alloc_string (len);
+ memcpy (String_val (strv), str, len);
+ CAMLreturn (strv);
+}
+
+CAMLprim value
+perl4caml_hv_iterval (value hvv, value hev)
+{
+ CAMLparam2 (hvv, hev);
+ CAMLlocal1 (svv);
+ HV *hv = Hv_val (hvv);
+ HE *he = He_val (hev);
+ SV *sv = hv_iterval (hv, he);
+ SvREFCNT_inc (sv);
+ svv = Val_sv (sv);
+ CAMLreturn (svv);
+}
+
+CAMLprim value
+perl4caml_hv_iternextsv (value hvv)
+{
+ CAMLparam1 (hvv);
+ CAMLlocal3 (strv, svv, rv);
+ HV *hv = Hv_val (hvv);
+ char *str; I32 len;
+ SV *sv = hv_iternextsv (hv, &str, &len);
+ if (sv == NULL) caml_raise_not_found ();
+ SvREFCNT_inc (sv);
+ svv = Val_sv (sv);
+ strv = caml_alloc_string (len);
+ memcpy (String_val (strv), str, len);
+ /* Construct a tuple (strv, svv). */
+ rv = caml_alloc_tuple (2);
+ Field (rv, 0) = strv;
+ Field (rv, 1) = svv;
+ CAMLreturn (rv);
+}
+
+CAMLprim value