Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0004812OCamlOCaml generalpublic2009-06-03 21:432012-09-17 14:10
Reportergoswin 
Assigned To 
PriorityhighSeverityminorReproducibilityalways
StatusacknowledgedResolutionopen 
PlatformOSOS Version
Product Version 
Target Version4.00.2+devFixed in Version 
Summary0004812: Add extern int code_of_unix_error (value error);
DescriptionThe 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 convertion.
Additional InformationRational:
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;
}
TagsNo tags attached.
Attached Files? file icon code_of_unix_error.dpatch [^] (1,342 bytes) 2009-06-03 21:43

- Relationships

-  Notes
There are no notes attached to this issue.

- Issue History
Date Modified Username Field Change
2009-06-03 21:43 goswin New Issue
2009-06-03 21:43 goswin File Added: code_of_unix_error.dpatch
2011-05-31 15:44 doligez Status new => acknowledged
2012-07-11 14:47 doligez Priority normal => high
2012-07-11 14:47 doligez Target Version => 4.01.0+dev
2012-07-31 13:36 doligez Target Version 4.01.0+dev => 4.00.1+dev
2012-09-17 14:10 doligez Target Version 4.00.1+dev => 4.00.2+dev


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker