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

FreeBSD and OpenBSD support #15

Open
anuragsoni opened this issue Nov 25, 2021 · 0 comments
Open

FreeBSD and OpenBSD support #15

anuragsoni opened this issue Nov 25, 2021 · 0 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@anuragsoni
Copy link
Owner

So far this library has been just tested on macOS. We should test this on the various BSD systems (starting with FreeBSD, OpenBSD), and add tests to ensure the library works on them.

Some differences across the various systems is the type definition for kevent.

macOS:

     struct kevent {
             uintptr_t       ident;          /* identifier for this event */
             int16_t         filter;         /* filter for event */
             uint16_t        flags;          /* general flags */
             uint32_t        fflags;         /* filter-specific flags */
             intptr_t        data;           /* filter-specific data */
             void            *udata;         /* opaque user data identifier */
     };

NetBSD

     struct kevent {
             uintptr_t ident;        /* identifier for this event */
             uint32_t  filter;       /* filter for event */
             uint32_t  flags;        /* action flags for kqueue */
             uint32_t  fflags;       /* filter flag value */
             int64_t   data;         /* filter data value */
             void     *udata;        /* opaque user data identifier */
     };

openBSD:

struct kevent {
	uintptr_t   ident;	/* identifier for this event */
	short	    filter;	/* filter for event */
	u_short	    flags;	/* action flags for kqueue */
	u_int	    fflags;	/* filter flag value */
	int64_t	    data;	/* filter data value */
	void	   *udata;	/* opaque user data identifier */
};

FreeBSD:

     struct kevent {
	     uintptr_t	ident;	     /*	identifier for this event */
	     short     filter;	     /*	filter for event */
	     u_short   flags;	     /*	action flags for kqueue	*/
	     u_int     fflags;	     /*	filter flag value */
	     int64_t   data;	     /*	filter data value */
	     void      *udata;	     /*	opaque user data identifier */
	     uint64_t  ext[4];	     /*	extensions */
     };

Another area that will take some work is to go over the various filters and filter flags (NOTE_*), to add os specific support for each platform. We already use ppx_optcomp for some conditional compilation, we could leverage it further to work with filters and flags that aren't defined on all platforms. The list of variables generated by our dune setup that can be consumed via ppx_optcomp is available at

let vars =
[ "KQUEUE_AVAILABLE", C.C_define.Value.Switch (kqueue_available operating_systems)
; "FREEBSD", List.assoc "__FreeBSD__" operating_systems
; "OPENBSD", List.assoc "__OpenBSD__" operating_systems
; "DRAGONFLY", List.assoc "__DragonFly__" operating_systems
; "NETBSD", List.assoc "__NetBSD__" operating_systems
; "KQUEUE_ML_ARCH_SIXTYFOUR", List.assoc "ARCH_SIXTYFOUR" system

@anuragsoni anuragsoni added enhancement New feature or request help wanted Extra attention is needed labels Nov 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant