mllib: Add unsetenv(3) binding to Unix_utils.

Missing from the OCaml stdlib.  This implementation is the same as the
one in Jane St's Core, except we don't bother to throw an exception on
error.
This commit is contained in:
Richard W.M. Jones
2017-02-22 14:49:43 +00:00
parent 4b6a482bc8
commit 592c960c15
3 changed files with 18 additions and 0 deletions

View File

@@ -45,6 +45,7 @@ extern void unix_error (int errcode, char * cmdname, value arg) Noreturn;
extern value guestfs_int_mllib_dev_t_makedev (value majv, value minv);
extern value guestfs_int_mllib_dev_t_major (value devv);
extern value guestfs_int_mllib_dev_t_minor (value devv);
extern value guestfs_int_mllib_unsetenv (value strv);
extern int guestfs_int_mllib_exit (value rv) __attribute__((noreturn));
extern value guestfs_int_mllib_fnmatch (value patternv, value strv, value flagsv);
extern value guestfs_int_mllib_sync (value unitv);
@@ -73,6 +74,14 @@ guestfs_int_mllib_dev_t_minor (value devv)
return Val_int (minor (Int_val (devv)));
}
/* NB: This is a "noalloc" call. */
value
guestfs_int_mllib_unsetenv (value strv)
{
unsetenv (String_val (strv));
return Val_unit;
}
/* NB: This is a "noalloc" call. */
int
guestfs_int_mllib_exit (value rv)

View File

@@ -22,6 +22,10 @@ module Dev_t = struct
external minor : int -> int = "guestfs_int_mllib_dev_t_minor" "noalloc"
end
module Env = struct
external unsetenv : string -> unit = "guestfs_int_mllib_unsetenv" "noalloc"
end
module Exit = struct
external _exit : int -> 'a = "guestfs_int_mllib_exit" "noalloc"
end

View File

@@ -32,6 +32,11 @@ module Dev_t : sig
(** minor(3) *)
end
module Env : sig
val unsetenv : string -> unit
(** Unset named environment variable, see unsetenv(3). *)
end
module Exit : sig
val _exit : int -> 'a
(** Call _exit directly, ie. do not run OCaml atexit handlers. *)