[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#531756: marked as done (Add extern int code_of_unix_error (value error);)



Your message dated Fri, 28 Aug 2015 14:24:06 +0200
with message-id <55E052E6.10605@debian.org>
and subject line Re: Bug#531756: [ocaml] code_of_unix_error available now
has caused the Debian Bug report #531756,
regarding Add extern int code_of_unix_error (value error);
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact owner@bugs.debian.org
immediately.)


-- 
531756: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=531756
Debian Bug Tracking System
Contact owner@bugs.debian.org with problems
--- Begin Message ---
Package: ocaml
Version: 3.11.0-1a0.mrvn.1
Severity: wishlist
Tags: patch

Hi,

the unixsupport.h header provides functions to convert unix errno into
ocamls Unix.error, which is sufficient for most applications. The
attached patch adds a function for the reverse conversion.

See http://caml.inria.fr/mantis/view.php?id=4812 for upstreams bugreport.

Rational:
For libfuse bindings I need to convert Unix.error to errno
numbers. The C stubs call an ocaml closure and expect usualy a string
as return value or an Unix.Unix_error exception in case of an
error. The stubs need to catch the exception, convert them back to
unix errno numbers and return -err to libfuse. The code looks
something like this:

static int readlink_stub(const char *name, char *buf, size_t size) {
  int res = 0;
  leave_blocking_section();
  CAMLparam0();
  CAMLlocal3(ml_name, ml_res, ml_exn);

  ml_name = caml_copy_string(name);
  value ml_res = caml_callback2(readlink_callback, ml_name, Val_int(size));
  if (Is_exception_result(ml_res)) {
    ml_exn = Extract_exception(ml_res);
    res = -code_of_unix_error(Field(ml_exn, 1));
  } else {
    strncpy(buf, String_val(ml_res), size);
  }
  enter_blocking_section();
  return res;
}

MfG
	Goswin

-- System Information:
Debian Release: squeeze/sid
  APT prefers unstable-i386
  APT policy: (500, 'unstable-i386'), (500, 'unstable'), (200, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.29.4-frosties-1
Locale: LANG=C, LC_CTYPE=de_DE (charmap=ISO-8859-1)
Shell: /bin/sh linked to /bin/bash

Versions of packages ocaml depends on:
ii  libx11-dev             2:1.2.1-1         X11 client-side library (developme
ii  ocaml-base             3.11.0-1a0.mrvn.1 Runtime system for OCaml bytecode 
ii  ocaml-nox              3.11.0-1a0.mrvn.1 ML language implementation with a 

ocaml recommends no packages.

Versions of packages ocaml suggests:
ii  tcl8.4-dev                    8.4.19-3   Tcl (the Tool Command Language) v8
ii  tk8.4-dev                     8.4.19-3   Tk toolkit for Tcl and X11, v8.4 -

-- no debconf information
#! /bin/sh -e 
## code_of_unix_error.dpatch by Goswin von Brederlow <goswin-v-b@web.de>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: add code_of_unix_error() to unixsupport.[ch] (see OCaml PR#4812)

if [ $# -ne 1 ]; then
    echo "`basename $0`: script expects -patch|-unpatch as argument" >&2
    exit 1
fi
case "$1" in
    -patch) patch -f --no-backup-if-mismatch -p1 < $0;;
    -unpatch) patch -f --no-backup-if-mismatch -R -p1 < $0;;	
    *)
	echo "`basename $0`: script expects -patch|-unpatch as argument" >&2
	exit 1;;
esac

exit 0
@DPATCH@
--- ocaml-3.11.0.orig/otherlibs/unix/unixsupport.h
+++ ocaml-3.11.0/otherlibs/unix/unixsupport.h
@@ -20,6 +20,7 @@
 #define Nothing ((value) 0)
 
 extern value unix_error_of_code (int errcode);
+extern int code_of_unix_error (value error);
 extern void unix_error (int errcode, char * cmdname, value arg) Noreturn;
 extern void uerror (char * cmdname, value arg) Noreturn;
 
--- ocaml-3.11.0.orig/otherlibs/unix/unixsupport.c
+++ ocaml-3.11.0/otherlibs/unix/unixsupport.c
@@ -263,6 +263,15 @@
   return err;
 }
 
+extern int code_of_unix_error (value error)
+{
+  if (Is_block(error)) {
+    return Int_val(Field(error, 0));
+  } else {
+    return error_table[Int_val(error)];
+  }
+}
+
 void unix_error(int errcode, char *cmdname, value cmdarg)
 {
   value res;

--- End Message ---
--- Begin Message ---
Version: 4.01.0-1

Le 23/10/2014 15:23, Török Edwin a écrit :
> With OCaml 4.01 I have this function now, can this bug be closed?
> /usr/include/caml/unixsupport.h:extern int code_of_unix_error (value error);

Closing.

-- 
Stéphane

--- End Message ---

Reply to: