Skip to content
This repository has been archived by the owner on Dec 9, 2022. It is now read-only.

Commit

Permalink
Merge pull request #12 from dsheets/sint
Browse files Browse the repository at this point in the history
Switch errno from int (31 or 63 bits) to Ctypes.sint (32 or 64 bits).
  • Loading branch information
dsheets authored Jul 26, 2016
2 parents c00f8f2 + a53277b commit 2fdf03b
Show file tree
Hide file tree
Showing 12 changed files with 489 additions and 483 deletions.
3 changes: 3 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
0.5.0 (2016-07-26):
* Switch errno from int to Ctypes.sint

0.4.2 (2016-06-01):
* Add support for ctypes 0.6.0

Expand Down
2 changes: 1 addition & 1 deletion META
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "0.4.2"
version = "0.5.0"
description = "Unix errno types, maps, and support"
requires = "result bytes"
archive(byte) = "errno_.cma"
Expand Down
3 changes: 2 additions & 1 deletion lib/_tags
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
<*.{ml,mli}>: package(bytes), package(result)
<*.{ml,mli}>: package(bytes), package(result), package(ctypes)

319 changes: 160 additions & 159 deletions lib/errno.ml
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ type t =
| ENODATA
| ETIME
| ENOSR
| EUNKNOWNERR of int
| EUNKNOWNERR of Signed.sint

type error = {
errno : t list;
Expand All @@ -181,163 +181,163 @@ type error = {
exception Error of error

type defns = {
e2big : int option;
eacces : int option;
eaddrinuse : int option;
eaddrnotavail : int option;
eafnosupport : int option;
eagain : int option;
ealready : int option;
ebadf : int option;
ebadmsg : int option;
ebusy : int option;
ecanceled : int option;
echild : int option;
econnaborted : int option;
econnrefused : int option;
econnreset : int option;
edeadlk : int option;
edestaddrreq : int option;
edom : int option;
edquot : int option;
eexist : int option;
efault : int option;
efbig : int option;
ehostdown : int option;
ehostunreach : int option;
eidrm : int option;
eilseq : int option;
einprogress : int option;
eintr : int option;
einval : int option;
eio : int option;
eisconn : int option;
eisdir : int option;
eloop : int option;
emfile : int option;
emlink : int option;
emsgsize : int option;
emultihop : int option;
enametoolong : int option;
enetdown : int option;
enetreset : int option;
enetunreach : int option;
enfile : int option;
enobufs : int option;
enodev : int option;
enoent : int option;
enoexec : int option;
enolck : int option;
enolink : int option;
enomem : int option;
enomsg : int option;
enoprotoopt : int option;
enospc : int option;
enosys : int option;
enotblk : int option;
enotconn : int option;
enotdir : int option;
enotempty : int option;
enotrecoverable : int option;
enotsock : int option;
enotsup : int option;
enotty : int option;
enxio : int option;
eopnotsupp : int option;
eoverflow : int option;
eownerdead : int option;
eperm : int option;
epfnosupport : int option;
epipe : int option;
eproto : int option;
eprotonosupport : int option;
eprototype : int option;
erange : int option;
eremote : int option;
erofs : int option;
eshutdown : int option;
esocktnosupport : int option;
espipe : int option;
esrch : int option;
estale : int option;
etimedout : int option;
etoomanyrefs : int option;
etxtbsy : int option;
eusers : int option;
ewouldblock : int option;
exdev : int option;
echrng : int option;
el2nsync : int option;
el3hlt : int option;
el3rst : int option;
elnrng : int option;
eunatch : int option;
enocsi : int option;
el2hlt : int option;
ebade : int option;
ebadr : int option;
exfull : int option;
enoano : int option;
ebadrqc : int option;
ebadslt : int option;
ebfont : int option;
enonet : int option;
enopkg : int option;
eadv : int option;
esrmnt : int option;
ecomm : int option;
edotdot : int option;
enotuniq : int option;
ebadfd : int option;
eremchg : int option;
elibacc : int option;
elibbad : int option;
elibscn : int option;
elibmax : int option;
elibexec : int option;
erestart : int option;
estrpipe : int option;
euclean : int option;
enotnam : int option;
enavail : int option;
eisnam : int option;
eremoteio : int option;
enomedium : int option;
emediumtype : int option;
enokey : int option;
ekeyexpired : int option;
ekeyrevoked : int option;
ekeyrejected : int option;
erfkill : int option;
ehwpoison : int option;
epwroff : int option;
edeverr : int option;
ebadexec : int option;
ebadarch : int option;
eshlibvers : int option;
ebadmacho : int option;
enopolicy : int option;
eqfull : int option;
edoofus : int option;
enotcapable : int option;
ecapmode : int option;
eproclim : int option;
ebadrpc : int option;
erpcmismatch : int option;
eprogunavail : int option;
eprogmismatch : int option;
eprocunavail : int option;
eftype : int option;
eauth : int option;
eneedauth : int option;
enoattr : int option;
enostr : int option;
enodata : int option;
etime : int option;
enosr : int option;
e2big : Signed.sint option;
eacces : Signed.sint option;
eaddrinuse : Signed.sint option;
eaddrnotavail : Signed.sint option;
eafnosupport : Signed.sint option;
eagain : Signed.sint option;
ealready : Signed.sint option;
ebadf : Signed.sint option;
ebadmsg : Signed.sint option;
ebusy : Signed.sint option;
ecanceled : Signed.sint option;
echild : Signed.sint option;
econnaborted : Signed.sint option;
econnrefused : Signed.sint option;
econnreset : Signed.sint option;
edeadlk : Signed.sint option;
edestaddrreq : Signed.sint option;
edom : Signed.sint option;
edquot : Signed.sint option;
eexist : Signed.sint option;
efault : Signed.sint option;
efbig : Signed.sint option;
ehostdown : Signed.sint option;
ehostunreach : Signed.sint option;
eidrm : Signed.sint option;
eilseq : Signed.sint option;
einprogress : Signed.sint option;
eintr : Signed.sint option;
einval : Signed.sint option;
eio : Signed.sint option;
eisconn : Signed.sint option;
eisdir : Signed.sint option;
eloop : Signed.sint option;
emfile : Signed.sint option;
emlink : Signed.sint option;
emsgsize : Signed.sint option;
emultihop : Signed.sint option;
enametoolong : Signed.sint option;
enetdown : Signed.sint option;
enetreset : Signed.sint option;
enetunreach : Signed.sint option;
enfile : Signed.sint option;
enobufs : Signed.sint option;
enodev : Signed.sint option;
enoent : Signed.sint option;
enoexec : Signed.sint option;
enolck : Signed.sint option;
enolink : Signed.sint option;
enomem : Signed.sint option;
enomsg : Signed.sint option;
enoprotoopt : Signed.sint option;
enospc : Signed.sint option;
enosys : Signed.sint option;
enotblk : Signed.sint option;
enotconn : Signed.sint option;
enotdir : Signed.sint option;
enotempty : Signed.sint option;
enotrecoverable : Signed.sint option;
enotsock : Signed.sint option;
enotsup : Signed.sint option;
enotty : Signed.sint option;
enxio : Signed.sint option;
eopnotsupp : Signed.sint option;
eoverflow : Signed.sint option;
eownerdead : Signed.sint option;
eperm : Signed.sint option;
epfnosupport : Signed.sint option;
epipe : Signed.sint option;
eproto : Signed.sint option;
eprotonosupport : Signed.sint option;
eprototype : Signed.sint option;
erange : Signed.sint option;
eremote : Signed.sint option;
erofs : Signed.sint option;
eshutdown : Signed.sint option;
esocktnosupport : Signed.sint option;
espipe : Signed.sint option;
esrch : Signed.sint option;
estale : Signed.sint option;
etimedout : Signed.sint option;
etoomanyrefs : Signed.sint option;
etxtbsy : Signed.sint option;
eusers : Signed.sint option;
ewouldblock : Signed.sint option;
exdev : Signed.sint option;
echrng : Signed.sint option;
el2nsync : Signed.sint option;
el3hlt : Signed.sint option;
el3rst : Signed.sint option;
elnrng : Signed.sint option;
eunatch : Signed.sint option;
enocsi : Signed.sint option;
el2hlt : Signed.sint option;
ebade : Signed.sint option;
ebadr : Signed.sint option;
exfull : Signed.sint option;
enoano : Signed.sint option;
ebadrqc : Signed.sint option;
ebadslt : Signed.sint option;
ebfont : Signed.sint option;
enonet : Signed.sint option;
enopkg : Signed.sint option;
eadv : Signed.sint option;
esrmnt : Signed.sint option;
ecomm : Signed.sint option;
edotdot : Signed.sint option;
enotuniq : Signed.sint option;
ebadfd : Signed.sint option;
eremchg : Signed.sint option;
elibacc : Signed.sint option;
elibbad : Signed.sint option;
elibscn : Signed.sint option;
elibmax : Signed.sint option;
elibexec : Signed.sint option;
erestart : Signed.sint option;
estrpipe : Signed.sint option;
euclean : Signed.sint option;
enotnam : Signed.sint option;
enavail : Signed.sint option;
eisnam : Signed.sint option;
eremoteio : Signed.sint option;
enomedium : Signed.sint option;
emediumtype : Signed.sint option;
enokey : Signed.sint option;
ekeyexpired : Signed.sint option;
ekeyrevoked : Signed.sint option;
ekeyrejected : Signed.sint option;
erfkill : Signed.sint option;
ehwpoison : Signed.sint option;
epwroff : Signed.sint option;
edeverr : Signed.sint option;
ebadexec : Signed.sint option;
ebadarch : Signed.sint option;
eshlibvers : Signed.sint option;
ebadmacho : Signed.sint option;
enopolicy : Signed.sint option;
eqfull : Signed.sint option;
edoofus : Signed.sint option;
enotcapable : Signed.sint option;
ecapmode : Signed.sint option;
eproclim : Signed.sint option;
ebadrpc : Signed.sint option;
erpcmismatch : Signed.sint option;
eprogunavail : Signed.sint option;
eprogmismatch : Signed.sint option;
eprocunavail : Signed.sint option;
eftype : Signed.sint option;
eauth : Signed.sint option;
eneedauth : Signed.sint option;
enoattr : Signed.sint option;
enostr : Signed.sint option;
enodata : Signed.sint option;
etime : Signed.sint option;
enosr : Signed.sint option;
}

type index = (int, t) Hashtbl.t
type index = (Signed.sint, t) Hashtbl.t

let empty_defns = {
e2big = None;
Expand Down Expand Up @@ -971,7 +971,7 @@ let to_string = function
| ENODATA -> "ENODATA"
| ETIME -> "ETIME"
| ENOSR -> "ENOSR"
| EUNKNOWNERR x -> "EUNKNOWNERR_"^(string_of_int x)
| EUNKNOWNERR x -> "EUNKNOWNERR_"^(Signed.SInt.to_string x)

let of_string = function
| "E2BIG" -> Some E2BIG
Expand Down Expand Up @@ -1459,7 +1459,8 @@ let string_of_defns defns =
let buf = Buffer.create 1024 in
iter_defns defns
(fun code symbol ->
Buffer.add_string buf (Printf.sprintf "%s\t%d\n" (to_string symbol) code)
Buffer.add_string buf (Printf.sprintf "%s\t%s\n" (to_string symbol)
(Signed.SInt.to_string code))
)
(fun symbol ->
Buffer.add_string buf (Printf.sprintf "%s\t\n" (to_string symbol))
Expand All @@ -1471,7 +1472,7 @@ let defns_of_string s =
try
let symbol, code, off = Scanf.sscanf s "%s\t%s\n" (fun symbol_s code_s ->
of_string symbol_s,
(if code_s = "" then None else Some (int_of_string code_s)),
(if code_s = "" then None else Some (Signed.SInt.of_string code_s)),
String.(length symbol_s + 1 + length code_s + 1)
) in
let defns = match symbol with
Expand Down
Loading

0 comments on commit 2fdf03b

Please sign in to comment.