Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make useconds_t a concrete, unsigned type. Add suseconds_t. #620

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/ctypes-top/ctypes_printers.ml
Expand Up @@ -65,6 +65,8 @@ let format_time_t fmt v =
Ctypes.format PosixTypes.time_t fmt v
let format_useconds_t fmt v =
Ctypes.format PosixTypes.useconds_t fmt v
let format_suseconds_t fmt v =
Ctypes.format PosixTypes.suseconds_t fmt v
let format_ldouble fmt v =
Format.fprintf fmt "<ldouble %s>" (LDouble.to_string v)
let format_complexld fmt v =
Expand Down
1 change: 1 addition & 0 deletions src/ctypes-top/install_ctypes_printers.ml
Expand Up @@ -31,6 +31,7 @@ let printers = [ "Ctypes_printers.format_typ";
"Ctypes_printers.format_ssize_t";
"Ctypes_printers.format_time_t";
"Ctypes_printers.format_useconds_t";
"Ctypes_printers.format_suseconds_t";
"Ctypes_printers.format_ldouble";
"Ctypes_printers.format_complexld";]

Expand Down
6 changes: 5 additions & 1 deletion src/ctypes/posixTypes.ml
Expand Up @@ -74,6 +74,7 @@ external typeof_pid_t : unit -> Ctypes_static.arithmetic = "ctypes_typeof_pid_t"
external typeof_ssize_t : unit -> Ctypes_static.arithmetic = "ctypes_typeof_ssize_t"
external typeof_time_t : unit -> Ctypes_static.arithmetic = "ctypes_typeof_time_t"
external typeof_useconds_t : unit -> Ctypes_static.arithmetic = "ctypes_typeof_useconds_t"
external typeof_suseconds_t : unit -> Ctypes_static.arithmetic = "ctypes_typeof_suseconds_t"

module Clock = (val mkArithmetic_abstract (typeof_clock_t ()) : Abstract)
module Dev = (val mkArithmetic "dev_t" (typeof_dev_t ()))
Expand All @@ -89,7 +90,8 @@ struct
end
module Ssize = (val mkSigned "ssize_t" (typeof_ssize_t ()))
module Time = (val mkArithmetic "time_t" (typeof_time_t ()))
module Useconds = (val mkArithmetic_abstract (typeof_useconds_t ()) : Abstract)
module Useconds = (val mkArithmetic "useconds_t" (typeof_useconds_t ()))
module Suseconds = (val mkSigned "suseconds_t" (typeof_suseconds_t ()))

type clock_t = Clock.t
type dev_t = Dev.t
Expand All @@ -102,6 +104,7 @@ type size_t = Size.t
type ssize_t = Ssize.t
type time_t = Time.t
type useconds_t = Useconds.t
type suseconds_t = Suseconds.t

let clock_t = Clock.t
let dev_t = Dev.t
Expand All @@ -114,6 +117,7 @@ let size_t = Size.t
let ssize_t = Ssize.t
let time_t = Time.t
let useconds_t = Useconds.t
let suseconds_t = Suseconds.t

(* Non-arithmetic types *)

Expand Down
6 changes: 5 additions & 1 deletion src/ctypes/posixTypes.mli
Expand Up @@ -20,6 +20,8 @@ module Off : Signed.S
module Pid : Signed.S
module Ssize : Signed.S
module Time : Unsigned.S
module Useconds : Unsigned.S
module Suseconds : Signed.S

type clock_t
type dev_t = Dev.t
Expand All @@ -31,7 +33,8 @@ type pid_t = Pid.t
type size_t = Unsigned.size_t
type ssize_t = Ssize.t
type time_t = Time.t
type useconds_t
type useconds_t = Useconds.t
type suseconds_t = Suseconds.t

(** {3 Values representing POSIX arithmetic types} *)

Expand All @@ -46,6 +49,7 @@ val size_t : size_t typ
val ssize_t : ssize_t typ
val time_t : time_t typ
val useconds_t : useconds_t typ
val suseconds_t : suseconds_t typ

(* non-arithmetic types from <sys/types.h> *)
(** {2 POSIX non-arithmetic types} *)
Expand Down
1 change: 1 addition & 0 deletions src/ctypes/posix_types_stubs.c
Expand Up @@ -77,6 +77,7 @@ EXPOSE_TYPEINFO_S(pid_t)
EXPOSE_TYPEINFO(ssize_t)
EXPOSE_TYPEINFO(time_t)
EXPOSE_TYPEINFO(useconds_t)
EXPOSE_TYPEINFO(suseconds_t)
#if !defined _WIN32 || defined __CYGWIN__
EXPOSE_TYPEINFO(nlink_t)
#else
Expand Down