Vendor things

This commit is contained in:
John Doty 2024-03-08 11:03:01 -08:00
parent 5deceec006
commit 977e3c17e5
19434 changed files with 10682014 additions and 0 deletions

View file

@ -0,0 +1 @@
{"files":{"CHANGELOG.md":"73de6eb76bc3be448520fc2df1103d67a0c598e22619baf7230f87b6956191ad","Cargo.toml":"3f0528737fd2878c4f60588fd839c153677de3b0276ef5eeef53aa92b95c43f2","LICENSE":"9dc7535841863372cb757676c5acd69c010572a85df23d3467d6bb3cc2829e84","README.md":"a9a0ee0701d5e0e31deb8471f26e0248913e3bbae9fb969aab7bfe80b0fc1839","Vagrantfile":"87be6ef9d9b98bf81db09d879e2407eff142f8ffa25b10f4b93a26841c54c8d0","src/constants/darwin.rs":"4823a6dc9e7b54f5c50b9fc3eb6cc733d81bde528b70698e67ea73577df3ed52","src/constants/dragonfly.rs":"faea758ccc5c2870a7f3fdb3c0182c4ed632d17ed1af81fdab096f23fd9f42da","src/constants/freebsd.rs":"f95bf39bf2d884adf3df2432b7dba1dabc069f36a6fd11e16fcc08f9c6acf321","src/constants/mod.rs":"72baddd7eb7c5cf8408ecbb186ab4c3289d7e97efdc5f248bd637adcadd617bf","src/constants/netbsd.rs":"699ba5b5ea1cc39491f1fea11889d047b447c74c80380913fdfa40e2e1da980c","src/constants/openbsd.rs":"dc0e4840e359ece071768555dcc756a6f864eab021e48668bab41a976dee3e1e","src/lib.rs":"61ff65854b757078798c838c6dc586cbdbf3a7215d34a45aef557ce4e644626a"},"package":"ed9625ffda8729b85e45cf04090035ac368927b8cebc34898e7c120f52e4838b"}

View file

@ -0,0 +1,32 @@
# Changelog
## 1.0.4
* #4: Adds support for iOS
## 1.0.3
* #1: fixes compiler error on NetBSD
## 1.0.2
* !2: fixes compiler error on darwin
## 1.0.1
* !1: fixes bug where watching multiple files on FreeBSD would fail
## 1.0.0
### Breaking
* `kevent.data` changed from `int64_t` -> `i64`
* Bumped `bitflags`: Now all bitflag constants must be qualified:
`EV_DELETE` -> `EventFlag::EV_DELETE`
`NOTE_WRITE` > `FilterFlag::NOT_WRITE`
### Others
* Updated to rust edition 2018
* Various clippy warnings

View file

@ -0,0 +1,51 @@
# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
#
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
# to registry (e.g., crates.io) dependencies.
#
# If you are reading this file be aware that the original Cargo.toml
# will likely look very different (and much more reasonable).
# See Cargo.toml.orig for the original contents.
[package]
edition = "2018"
name = "kqueue-sys"
version = "1.0.4"
authors = [
"William Orr <will@worrbase.com>",
"Daniel (dmilith) Dettlaff <dmilith@me.com>",
]
description = "Low-level kqueue interface for BSDs"
readme = "README.md"
keywords = [
"kqueue",
"kevent",
"bsd",
"darwin",
"macos",
]
categories = [
"external-ffi-bindings",
"no-std",
"os::unix-apis",
"filesystem",
]
license = "MIT"
repository = "https://gitlab.com/rust-kqueue/rust-kqueue-sys"
[package.metadata.docs.rs]
targets = [
"x86_64-unknown-freebsd",
"x86_64-unknown-dragonfly",
"x86_64-unknown-openbsd",
"x86_64-unknown-netbsd",
"x86_64-apple-darwin",
]
[dependencies.bitflags]
version = "^1.2.1"
[dependencies.libc]
version = "^0.2.74"

19
third-party/vendor/kqueue-sys/LICENSE vendored Normal file
View file

@ -0,0 +1,19 @@
Copyright (c) 2016 William Orr <will@worrbase.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -0,0 +1,8 @@
# kqueue-sys
[![Gitlab
Pipelines](https://gitlab.com/rust-kqueue/rust-kqueue-sys/badges/main/pipeline.svg)](https://gitlab.com/rust-kqueue/rust-kqueue-sys/-/commits/main)
[![Travis Build
Status](https://travis-ci.com/worr/rust-kqueue-sys.svg?branch=main)](https://travis-ci.com/worr/rust-kqueue-sys)
Low-level `kqueue(2)` ffi layer for `kqueue` crate

View file

@ -0,0 +1,74 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.
# Every Vagrant development environment requires a box. You can search for
# boxes at https://atlas.hashicorp.com/search.
config.vm.box = "bento/freebsd-10.3"
# Disable automatic box update checking. If you disable this, then
# boxes will only be checked for updates when the user runs
# `vagrant box outdated`. This is not recommended.
# config.vm.box_check_update = false
config.vm.network "private_network", ip: "172.16.1.2"
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
# config.vm.network "forwarded_port", guest: 80, host: 8080
# Create a private network, which allows host-only access to the machine
# using a specific IP.
# config.vm.network "private_network", ip: "192.168.33.10"
# Create a public network, which generally matched to bridged network.
# Bridged networks make the machine appear as another physical device on
# your network.
# config.vm.network "public_network"
# Share an additional folder to the guest VM. The first argument is
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
config.vm.synced_folder ".", "/vagrant_data", :nfs => true, :nfs_udp => false, :nfs_options => ['vers=3']
# Provider-specific configuration so you can fine-tune various
# backing providers for Vagrant. These expose provider-specific options.
# Example for VirtualBox:
#
# config.vm.provider "virtualbox" do |vb|
# # Display the VirtualBox GUI when booting the machine
# vb.gui = true
#
# # Customize the amount of memory on the VM:
# vb.memory = "1024"
# end
#
# View the documentation for the provider you are using for more
# information on available options.
# Define a Vagrant Push strategy for pushing to Atlas. Other push strategies
# such as FTP and Heroku are also available. See the documentation at
# https://docs.vagrantup.com/v2/push/atlas.html for more information.
# config.push.define "atlas" do |push|
# push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME"
# end
# Enable provisioning with a shell script. Additional provisioners such as
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
# documentation for more information about their specific syntax and use.
config.vm.provision "shell", inline: <<-SHELL
sudo pkg update
sudo pkg install -y rust cargo
sudo echo -e '\nrpc_lockd_enable=YES' >> /etc/rc.conf
sudo service lockd start
SHELL
end

View file

@ -0,0 +1,88 @@
use bitflags::bitflags;
use libc::{c_uint, c_ushort};
#[allow(non_camel_case_types)]
#[derive(Clone, Copy, Debug, PartialEq)]
#[repr(i16)]
pub enum EventFilter {
EVFILT_READ = -1,
EVFILT_WRITE = -2,
EVFILT_AIO = -3, /* attached to aio requests */
EVFILT_VNODE = -4, /* attached to vnodes */
EVFILT_PROC = -5, /* attached to struct proc */
EVFILT_SIGNAL = -6, /* attached to struct proc */
EVFILT_TIMER = -7, /* timers */
EVFILT_MACHPORT = -8, /* Mach portsets */
EVFILT_FS = -9, /* Filesystem events */
EVFILT_USER = -10, /* User events */
EVFILT_VM = -12, /* Virtual memory events */
EVFILT_SYSCOUNT = 14,
}
bitflags! {
pub struct EventFlag: c_ushort {
const EV_ADD = 0x0001; /* add event to kq (implies enable) */
const EV_DELETE = 0x0002; /* delete event from kq */
const EV_ENABLE = 0x0004; /* enable event */
const EV_DISABLE = 0x0008; /* disable event (not reported) */
const EV_UDATA_SPECIFIC = 0x0100; /* unique kevent per udata value */
/* ... in combination with EV_DELETE */
/* will defer delete until udata-specific */
/* event enabled. EINPROGRESS will be */
/* returned to indicate the deferral */
const EV_ONESHOT = 0x0010; /* only report one occurrence */
const EV_CLEAR = 0x0020; /* clear event state after reporting */
const EV_RECEIPT = 0x0040; /* force EV_ERROR on success, data == 0 */
const EV_DISPATCH = 0x0080; /* disable event after reporting */
const EV_SYSFLAGS = 0xF000; /* reserved by system */
const EV_FLAG0 = 0x1000; /* filter-specific flag */
const EV_FLAG1 = 0x2000; /* filter-specific flag */
const EV_EOF = 0x8000; /* EOF detected */
const EV_ERROR = 0x4000; /* error, data contains errno */
}
}
bitflags! {
pub struct FilterFlag: c_uint {
const NOTE_FFNOP = 0x00000000; /* ignore input fflags */
const NOTE_FFAND = 0x40000000; /* and fflags */
const NOTE_FFOR = 0x80000000; /* or fflags */
const NOTE_FFCOPY = 0xc0000000; /* copy fflags */
const NOTE_FFCTRLMASK = 0xc0000000; /* mask for operations */
const NOTE_FFLAGSMASK = 0x00ffffff;
const NOTE_LOWAT = 0x00000001; /* low water mark */
const NOTE_DELETE = 0x00000001; /* vnode was removed */
const NOTE_WRITE = 0x00000002; /* data contents changed */
const NOTE_EXTEND = 0x00000004; /* size increased */
const NOTE_ATTRIB = 0x00000008; /* attributes changed */
const NOTE_LINK = 0x00000010; /* link count changed */
const NOTE_RENAME = 0x00000020; /* vnode was renamed */
const NOTE_REVOKE = 0x00000040; /* vnode access was revoked */
const NOTE_NONE = 0x00000080; /* No specific vnode event: to test for EVFILT_READ activation*/
const NOTE_EXIT = 0x80000000; /* process exited */
const NOTE_FORK = 0x40000000; /* process forked */
const NOTE_EXEC = 0x20000000; /* process exec'd */
const NOTE_SIGNAL = 0x08000000; /* shared with EVFILT_SIGNAL */
const NOTE_EXITSTATUS = 0x04000000; /* exit status to be returned, valid for child process only */
const NOTE_EXIT_DETAIL = 0x02000000; /* provide details on reasons for exit */
const NOTE_PDATAMASK = 0x000fffff; /* mask for signal & exit status */
const NOTE_PCTRLMASK = 0xf0000000;
const NOTE_SECONDS = 0x00000001; /* data is seconds */
const NOTE_USECONDS = 0x00000002; /* data is microseconds */
const NOTE_NSECONDS = 0x00000004; /* data is nanoseconds */
const NOTE_ABSOLUTE = 0x00000008; /* absolute timeout */
/* ... implicit EV_ONESHOT */
const NOTE_LEEWAY = 0x00000010; /* ext[1] holds leeway for power aware timers */
const NOTE_CRITICAL = 0x00000020; /* system does minimal timer coalescing */
const NOTE_BACKGROUND = 0x00000040; /* system does maximum timer coalescing */
const NOTE_VM_PRESSURE = 0x80000000; /* will react on memory pressure */
const NOTE_VM_PRESSURE_TERMINATE = 0x40000000; /* will quit on memory pressure, possibly after cleaning up dirty state */
const NOTE_VM_PRESSURE_SUDDEN_TERMINATE = 0x20000000; /* will quit immediately on memory pressure */
const NOTE_VM_ERROR = 0x10000000; /* there was an error */
const NOTE_TRACK = 0x00000001; /* follow across forks */
const NOTE_TRACKERR = 0x00000002; /* could not track child */
const NOTE_CHILD = 0x00000004; /* am a child process */
}
}

View file

@ -0,0 +1,67 @@
use bitflags::bitflags;
use libc::{c_uint, c_ushort};
#[allow(non_camel_case_types)]
#[derive(Clone, Copy, Debug, PartialEq)]
#[repr(i16)]
pub enum EventFilter {
EVFILT_READ = -1,
EVFILT_WRITE = -2,
EVFILT_AIO = -3,
EVFILT_VNODE = -4,
EVFILT_PROC = -5,
EVFILT_SIGNAL = -6,
EVFILT_TIMER = -7,
EVFILT_EXCEPT = -8,
EVFILT_USER = -9,
EVFILT_FS = -10,
EVFILT_SYSCOUNT = 10,
}
bitflags! {
pub struct EventFlag: c_ushort {
const EV_ADD = 0x0001;
const EV_DELETE = 0x0002;
const EV_ENABLE = 0x0004;
const EV_DISABLE = 0x0008;
const EV_ONESHOT = 0x0010;
const EV_CLEAR = 0x0020;
const EV_RECEIPT = 0x0040;
const EV_DISPATCH = 0x0080;
const EV_SYSFLAGS = 0xF000;
const EV_FLAG1 = 0x2000;
const EV_EOF = 0x8000;
const EV_ERROR = 0x4000;
const EV_NODATA = 0x1000;
}
}
bitflags! {
pub struct FilterFlag: c_uint {
const NOTE_FFNOP = 0x00000000;
const NOTE_FFAND = 0x40000000;
const NOTE_FFOR = 0x80000000;
const NOTE_FFCOPY = 0xc0000000;
const NOTE_FFCTRLMASK = 0xc0000000;
const NOTE_FFLAGSMASK = 0x00ffffff;
const NOTE_TRIGGER = 0x01000000;
const NOTE_LOWAT = 0x00000001;
const NOTE_OOB = 0x00000002;
const NOTE_DELETE = 0x00000001;
const NOTE_WRITE = 0x00000002;
const NOTE_EXTEND = 0x00000004;
const NOTE_ATTRIB = 0x00000008;
const NOTE_LINK = 0x00000010;
const NOTE_RENAME = 0x00000020;
const NOTE_REVOKE = 0x00000040;
const NOTE_EXIT = 0x80000000;
const NOTE_FORK = 0x40000000;
const NOTE_EXEC = 0x20000000;
const NOTE_SIGNAL = 0x08000000;
const NOTE_PCTRLMASK = 0xf0000000;
const NOTE_PDATAMASK = 0x000fffff;
const NOTE_TRACK = 0x00000001;
const NOTE_TRACKERR = 0x00000002;
const NOTE_CHILD = 0x00000004;
}
}

View file

@ -0,0 +1,85 @@
use bitflags::bitflags;
use libc::{c_uint, c_ushort};
#[allow(non_camel_case_types)]
#[derive(Clone, Copy, Debug, PartialEq)]
#[repr(i16)]
pub enum EventFilter {
EVFILT_READ = -1,
EVFILT_WRITE = -2,
EVFILT_AIO = -3,
EVFILT_VNODE = -4,
EVFILT_PROC = -5,
EVFILT_SIGNAL = -6,
EVFILT_TIMER = -7,
EVFILT_PROCDESC = -8,
EVFILT_FS = -9,
EVFILT_LIO = -10,
EVFILT_USER = -11,
EVFILT_SENDFILE = -12,
EVFILT_EMPTY = -13,
EVFILT_SYSCOUNT = 13,
}
bitflags! {
pub struct EventFlag: c_ushort {
const EV_ADD = 0x0001;
const EV_DELETE = 0x0002;
const EV_ENABLE = 0x0004;
const EV_DISABLE = 0x0008;
const EV_FORCEONESHOT = 0x0100;
const EV_ONESHOT = 0x0010;
const EV_CLEAR = 0x0020;
const EV_RECEIPT = 0x0040;
const EV_DISPATCH = 0x0080;
const EV_SYSFLAGS = 0xF000;
const EV_DROP = 0x1000;
const EV_FLAG1 = 0x2000;
const EV_FLAG2 = 0x4000;
const EV_EOF = 0x8000;
const EV_ERROR = 0x4000;
}
}
bitflags! {
pub struct FilterFlag: c_uint {
const NOTE_FFNOP = 0x00000000;
const NOTE_FFAND = 0x40000000;
const NOTE_FFOR = 0x80000000;
const NOTE_FFCOPY = 0xc0000000;
const NOTE_FFCTRLMASK = 0xc0000000;
const NOTE_FFLAGSMASK = 0x00ffffff;
const NOTE_TRIGGER = 0x01000000;
const NOTE_LOWAT = 0x00000001;
const NOTE_FILE_POLL = 0x00000002;
const NOTE_DELETE = 0x00000001;
const NOTE_WRITE = 0x00000002;
const NOTE_EXTEND = 0x00000004;
const NOTE_ATTRIB = 0x00000008;
const NOTE_LINK = 0x00000010;
const NOTE_RENAME = 0x00000020;
const NOTE_REVOKE = 0x00000040;
const NOTE_OPEN = 0x00000080;
const NOTE_CLOSE = 0x00000100;
const NOTE_CLOSE_WRITE = 0x00000200;
const NOTE_READ = 0x00000400;
const NOTE_EXIT = 0x80000000;
const NOTE_FORK = 0x40000000;
const NOTE_EXEC = 0x20000000;
const NOTE_PCTRLMASK = 0xf0000000;
const NOTE_PDATAMASK = 0x000fffff;
const NOTE_TRACK = 0x00000001;
const NOTE_TRACKERR = 0x00000002;
const NOTE_CHILD = 0x00000004;
const NOTE_SECONDS = 0x00000001;
const NOTE_MSECONDS = 0x00000002;
const NOTE_USECONDS = 0x00000004;
const NOTE_NSECONDS = 0x00000008;
const NOTE_ABSTIME = 0x00000010;
}
}

View file

@ -0,0 +1,24 @@
#[cfg(any(target_os = "macos", target_os = "ios"))]
mod darwin;
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub use self::darwin::*;
#[cfg(target_os = "dragonfly")]
mod dragonfly;
#[cfg(target_os = "dragonfly")]
pub use self::dragonfly::*;
#[cfg(target_os = "freebsd")]
mod freebsd;
#[cfg(target_os = "freebsd")]
pub use self::freebsd::*;
#[cfg(target_os = "netbsd")]
mod netbsd;
#[cfg(target_os = "netbsd")]
pub use self::netbsd::*;
#[cfg(target_os = "openbsd")]
mod openbsd;
#[cfg(target_os = "openbsd")]
pub use self::openbsd::*;

View file

@ -0,0 +1,55 @@
use bitflags::bitflags;
#[allow(non_camel_case_types)]
#[repr(u32)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum EventFilter {
EVFILT_READ = 0,
EVFILT_WRITE = 1,
EVFILT_AIO = 2,
EVFILT_VNODE = 3,
EVFILT_PROC = 4,
EVFILT_SIGNAL = 5,
EVFILT_TIMER = 6,
EVFILT_SYSCOUNT = 7,
}
bitflags! {
pub struct EventFlag: u32 {
const EV_ADD = 0x0001;
const EV_DELETE = 0x0002;
const EV_ENABLE = 0x0004;
const EV_DISABLE = 0x0008;
const EV_ONESHOT = 0x0010;
const EV_CLEAR = 0x0020;
const EV_RECEIPT = 0x0040;
const EV_DISPATCH = 0x0080;
const EV_SYSFLAGS = 0xF000;
const EV_NODATA = 0x1000;
const EV_FLAG1 = 0x2000;
const EV_EOF = 0x8000;
const EV_ERROR = 0x4000;
}
}
bitflags! {
pub struct FilterFlag: u32 {
const NOTE_LOWAT = 0x00000001;
const NOTE_DELETE = 0x00000001;
const NOTE_WRITE = 0x00000002;
const NOTE_EXTEND = 0x00000004;
const NOTE_ATTRIB = 0x00000008;
const NOTE_LINK = 0x00000010;
const NOTE_RENAME = 0x00000020;
const NOTE_REVOKE = 0x00000040;
const NOTE_EXIT = 0x80000000;
const NOTE_FORK = 0x40000000;
const NOTE_EXEC = 0x20000000;
const NOTE_SIGNAL = 0x08000000;
const NOTE_PDATAMASK = 0x000fffff;
const NOTE_PCTRLMASK = 0xf0000000;
const NOTE_TRACK = 0x00000001;
const NOTE_TRACKERR = 0x00000002;
const NOTE_CHILD = 0x00000004;
}
}

View file

@ -0,0 +1,57 @@
use bitflags::bitflags;
use libc::{c_uint, c_ushort};
#[allow(non_camel_case_types)]
#[derive(Clone, Copy, Debug, PartialEq)]
#[repr(i16)]
pub enum EventFilter {
EVFILT_READ = -1,
EVFILT_WRITE = -2,
EVFILT_AIO = -3,
EVFILT_VNODE = -4,
EVFILT_PROC = -5,
EVFILT_SIGNAL = -6,
EVFILT_TIMER = -7,
EVFILT_SYSCOUNT = 7,
}
bitflags! {
pub struct EventFlag: c_ushort {
const EV_ADD = 0x0001;
const EV_DELETE = 0x0002;
const EV_ENABLE = 0x0004;
const EV_DISABLE = 0x0008;
const EV_ONESHOT = 0x0010;
const EV_CLEAR = 0x0020;
const EV_SYSFLAGS = 0xF000;
const EV_FLAG1 = 0x2000;
const EV_EOF = 0x8000;
const EV_ERROR = 0x4000;
}
}
bitflags! {
pub struct FilterFlag: c_uint {
const NOTE_LOWAT = 0x00000001;
const NOTE_EOF = 0x00000002;
const NOTE_DELETE = 0x00000001;
const NOTE_WRITE = 0x00000002;
const NOTE_EXTEND = 0x00000004;
const NOTE_ATTRIB = 0x00000008;
const NOTE_LINK = 0x00000010;
const NOTE_RENAME = 0x00000020;
const NOTE_REVOKE = 0x00000040;
const NOTE_TRUNCATE = 0x00000080;
const NOTE_EXIT = 0x80000000;
const NOTE_FORK = 0x40000000;
const NOTE_EXEC = 0x20000000;
const NOTE_SIGNAL = 0x08000000;
const NOTE_PCTRLMASK = 0xf0000000;
const NOTE_PDATAMASK = 0x000fffff;
const NOTE_TRACK = 0x00000001;
const NOTE_TRACKERR = 0x00000002;
const NOTE_CHILD = 0x00000004;
}
}

136
third-party/vendor/kqueue-sys/src/lib.rs vendored Normal file
View file

@ -0,0 +1,136 @@
#![no_std]
#[allow(unused_imports)]
use libc::{c_int, c_short, c_uint, c_ushort, c_void, intptr_t, size_t, timespec, uintptr_t};
#[cfg(not(target_os = "netbsd"))]
use core::ptr;
pub mod constants;
pub use self::constants::*;
#[cfg(not(target_os = "netbsd"))]
pub type EventListSize = c_int;
#[cfg(target_os = "netbsd")]
pub type EventListSize = size_t;
#[cfg(all(not(target_os = "netbsd"), not(target_os = "freebsd")))]
#[derive(Clone, Copy, Debug)]
#[repr(C)]
pub struct kevent {
pub ident: uintptr_t,
pub filter: EventFilter,
pub flags: EventFlag,
pub fflags: FilterFlag,
pub data: i64,
pub udata: *mut c_void,
}
#[cfg(target_os = "netbsd")]
#[derive(Clone, Copy, Debug)]
#[repr(C)]
pub struct kevent {
pub ident: uintptr_t,
pub filter: EventFilter,
pub flags: EventFlag,
pub fflags: FilterFlag,
pub data: i64,
pub udata: intptr_t,
}
#[cfg(target_os = "freebsd")]
#[derive(Clone, Copy, Debug)]
#[repr(C)]
pub struct kevent {
pub ident: uintptr_t,
pub filter: EventFilter,
pub flags: EventFlag,
pub fflags: FilterFlag,
pub data: i64,
pub udata: *mut c_void,
pub ext: [i64; 4],
}
impl kevent {
#[cfg(all(not(target_os = "netbsd"), not(target_os = "freebsd")))]
pub fn new(
ident: uintptr_t,
filter: EventFilter,
flags: EventFlag,
fflags: FilterFlag,
) -> kevent {
kevent {
ident,
filter,
flags,
fflags,
data: 0,
udata: ptr::null_mut(),
}
}
#[cfg(target_os = "netbsd")]
pub fn new(
ident: uintptr_t,
filter: EventFilter,
flags: EventFlag,
fflags: FilterFlag,
) -> kevent {
kevent {
ident,
filter,
flags,
fflags,
data: 0,
udata: 0,
}
}
#[cfg(target_os = "freebsd")]
pub fn new(
ident: uintptr_t,
filter: EventFilter,
flags: EventFlag,
fflags: FilterFlag,
) -> kevent {
kevent {
ident,
filter,
flags,
fflags,
data: 0,
udata: ptr::null_mut(),
ext: [0; 4],
}
}
}
#[allow(improper_ctypes)]
extern "C" {
pub fn kqueue() -> c_int;
pub fn kevent(
kq: c_int,
changelist: *const kevent,
nchanges: EventListSize,
eventlist: *mut kevent,
nevents: EventListSize,
timeout: *const timespec,
) -> c_int;
#[cfg(target_os = "netbsd")]
pub fn kqueue1(flags: c_int) -> c_int;
}
#[cfg(test)]
mod test {
use super::kqueue;
#[test]
fn test_kqueue() {
unsafe {
assert!(kqueue() > 0);
}
}
}