Vendor dependencies

This commit is contained in:
2026-08-01 16:11:49 +03:00
parent 7f139a0241
commit 6b5e7f0f8b
29706 changed files with 9575646 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
{"$comment":"This file only protects against accidental modifications. It is not a security mechanism and does not protect against malicious changes.","files":{".cargo_vcs_info.json":"6626d9e21adeb8638ea728a32d9c857dc5cd52f1a96cc58f5667b9ba5723aa88",".gitlab-ci.yml":"60501d5b8039d5940b3502641ca912046980914c6de5eb66e5f698d8fb92e5f0",".travis.yml":"3153642fff6c3a5bedd767c44ba441affcf57436da13c2a832f184a87bc31942","CHANGELOG.md":"cae3a8d36b12bfd1a7b4964be775cc3481b15e5c037961a865ec266235611d2f","Cargo.lock":"db82d78805eafc03095ec01f895b5366a854a05cd275ee401e255c3daffe2f06","Cargo.toml":"62029dc0d48ef8c8a6a127c81ba9fa068f93cd75230e32d96a377e04e7d613e2","Cargo.toml.orig":"cff598d3615bf06320befc06e914928e268e1aa8eef12e80f1409fe2726d1e75","LICENSE":"9dc7535841863372cb757676c5acd69c010572a85df23d3467d6bb3cc2829e84","README.md":"a9a0ee0701d5e0e31deb8471f26e0248913e3bbae9fb969aab7bfe80b0fc1839","Vagrantfile":"87be6ef9d9b98bf81db09d879e2407eff142f8ffa25b10f4b93a26841c54c8d0","src/constants/darwin.rs":"773f681741a20b6aceb941ed92562eb833b85f71bf8ce4daa4fd4e84ab68310d","src/constants/dragonfly.rs":"85704caa67d805a5f13a614b340bd02451c6e8cd56e7167dc4105423eaa3acf0","src/constants/freebsd.rs":"3f78c2fc09c26d4943a996d395eb7ec1f48c1eda191db673ad7ba6c7362f15f2","src/constants/mod.rs":"72baddd7eb7c5cf8408ecbb186ab4c3289d7e97efdc5f248bd637adcadd617bf","src/constants/netbsd.rs":"29815c84d580629d1f1802b8c0fc1aaf91a5d61f4dcbf1d1e51a82a4cf0d3929","src/constants/openbsd.rs":"b5e2b90c0f7c368db4dfa54dcd8ee82554bb683b1a1719109a9d2c3f6683f917","src/lib.rs":"61ff65854b757078798c838c6dc586cbdbf3a7215d34a45aef557ce4e644626a"},"package":"07293a4e297ac234359b510362495713f75ea345d5307140414f20c69ffeb087"}
+6
View File
@@ -0,0 +1,6 @@
{
"git": {
"sha1": "64ff895bb38867e73ce056a6a8b5dfc29345c47d"
},
"path_in_vcs": ""
}
+90
View File
@@ -0,0 +1,90 @@
# Use cargo to test the project
test:cargo:
stage: test
tags:
- ${TARGET}
parallel:
matrix:
- TARGET: freebsd
- TARGET: openbsd
coverage: '/TOTAL\s+(\d+\s+)+(\d+\.\d+\%)/'
script:
- rustc --version && cargo --version # Print version info for debugging
- echo -e "\e[0Ksection_start:`date +%s`:lint\r\e[0KLinting"
- cargo clippy --message-format=json --all-targets --all-features
-- -D warnings
> clippy.json
- echo -e "\e[0Ksection_end:`date +%s`:lint\r\e[0K"
# Coverage testing would go here. However, OpenBSD rust is not built
# with the required tooling for profiling builds.
- echo -e "\e[0Ksection_start:`date +%s`:test\r\e[0KRunning cargo nextest"
- if [[ "$(uname -s)" = "OpenBSD" ]]; then
cargo nextest run --workspace --cargo-verbose --tests;
else
cargo llvm-cov nextest --workspace --cargo-verbose --tests;
fi
- echo -e "\e[0Ksection_end:`date +%s`:test\r\e[0K"
- echo -e "\e[0Ksection_start:`date +%s`:deps\r\e[0KRunning cargo audit"
- gitlab-cargo-audit --output-path gl-dep-report.json
- echo -e "\e[0Ksection_end:`date +%s`:deps\r\e[0K"
after_script:
- cargo codeclimate --clippy --codeclimate-path gl-code-quality-report.json
- if [[ "$(uname -s)" = "Darwin" || "$(uname -s)" = "FreeBSD" ]]; then
cargo llvm-cov report --cobertura --output-path target/llvm-cov-target/cobertura.xml;
fi
variables:
RUST_BACKTRACE: full
CARGO_INCREMENTAL: 0
artifacts:
name: dhat-report
paths:
- dhat-heap.json
reports:
junit: target/nextest/default/junit.xml
codequality: gl-code-quality-report.json
dependency_scanning: gl-dep-report.json
coverage_report:
coverage_format: cobertura
path: target/llvm-cov-target/cobertura.xml
expire_in: 1 month
cache:
key: deps
paths:
- target/
cross:cargo:
image: rust:1.91
stage: build
tags:
- gitlab-org-docker
parallel:
matrix:
- TARGET: x86_64-unknown-netbsd
- TARGET: x86_64-unknown-freebsd
- TARGET: i686-unknown-freebsd
- TARGET: aarch64-apple-darwin
- TARGET: x86_64-apple-darwin
- TARGET: aarch64-apple-ios
- TARGET: x86_64-apple-ios
before_script:
- rustup component add clippy rustfmt
- rustup target add $TARGET
- curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
- cargo binstall cargo-sonar cargo-semver-checks
script:
- rustc --version && cargo --version # Print version info for debugging
- cargo fmt --check
- cargo build --target $TARGET
- cargo clippy --target $TARGET --message-format=json --all-targets --all-features
-- -D warnings
> clippy.json
- cargo semver-checks --target $TARGET
after_script:
- cargo codeclimate --clippy --codeclimate-path gl-code-quality-report.json
artifacts:
reports:
codequality: gl-code-quality-report.json
cache:
key: deps-$TARGET-cross
paths:
- target/
+13
View File
@@ -0,0 +1,13 @@
language: rust
rust:
- stable
- beta
- nightly
jobs:
allow_failures:
- rust: nightly
fast_finish: true
os:
- osx
- freebsd
+45
View File
@@ -0,0 +1,45 @@
# Changelog
## 1.1.2
* Add MSRV to `Cargo.toml`
## 1.1.1
* Derive `Eq`, `Hash`, `Ord`, `PartialOrd` on `EventFilter`
## 1.1.0
* Update bitflags to 2.x
* Bump Rust edition to 2021
## 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
+23
View File
@@ -0,0 +1,23 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "bitflags"
version = "2.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "843867be96c8daad0d758b57df9392b6d8d271134fce549de6ce169ff98a92af"
[[package]]
name = "kqueue-sys"
version = "1.1.2"
dependencies = [
"bitflags",
"libc",
]
[[package]]
name = "libc"
version = "0.2.183"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5b646652bf6661599e1da8901b3b9522896f01e736bad5f723fe7a3a27f899d"
+67
View File
@@ -0,0 +1,67 @@
# 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 = "2021"
rust-version = "1.65"
name = "kqueue-sys"
version = "1.1.2"
authors = [
"William Orr <will@worrbase.com>",
"Daniel (dmilith) Dettlaff <dmilith@me.com>",
]
build = false
autolib = false
autobins = false
autoexamples = false
autotests = false
autobenches = false
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-netbsd",
"x86_64-unknown-freebsd",
"i686-unknown-freebsd",
"x86_64-unknown-dragonfly",
"x86_64-unknown-openbsd",
"aarch64-apple-darwin",
"x86_64-apple-darwin",
"aarch64-apple-ios",
"x86_64-apple-ios",
]
[lib]
name = "kqueue_sys"
path = "src/lib.rs"
[dependencies.bitflags]
version = "2.11.0"
default-features = false
[dependencies.libc]
version = "^0.2.74"
+29
View File
@@ -0,0 +1,29 @@
[package]
name = "kqueue-sys"
version = "1.1.2"
authors = ["William Orr <will@worrbase.com>", "Daniel (dmilith) Dettlaff <dmilith@me.com>"]
description = "Low-level kqueue interface for BSDs"
license = "MIT"
keywords = ["kqueue", "kevent", "bsd", "darwin", "macos"]
categories = ["external-ffi-bindings", "no-std", "os::unix-apis", "filesystem"]
repository = "https://gitlab.com/rust-kqueue/rust-kqueue-sys"
readme = "README.md"
edition = "2021"
rust-version = "1.65"
[package.metadata.docs.rs]
targets = [
"x86_64-unknown-netbsd",
"x86_64-unknown-freebsd",
"i686-unknown-freebsd",
"x86_64-unknown-dragonfly",
"x86_64-unknown-openbsd",
"aarch64-apple-darwin",
"x86_64-apple-darwin",
"aarch64-apple-ios",
"x86_64-apple-ios",
]
[dependencies]
bitflags = { version = "2.11.0", default-features = false }
libc = "^0.2.74"
+19
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.
+8
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
+74
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
+128
View File
@@ -0,0 +1,128 @@
use bitflags::bitflags;
use libc::{c_uint, c_ushort};
#[allow(non_camel_case_types)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Ord, PartialOrd)]
#[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! {
#[repr(transparent)]
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash, Ord, PartialOrd)]
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 */
}
}
impl EventFlag {
/// Convert from underlying bit representation, preserving all
/// bits (even those not corresponding to a defined flag).
///
/// # Safety
///
/// The caller of the `bitflags!` macro can chose to allow or
/// disallow extra bits for their bitflags type.
///
/// The caller of `from_bits_unchecked()` has to ensure that
/// all bits correspond to a defined flag or that extra bits
/// are valid for this bitflags type.
#[deprecated = "use the safe `from_bits_retain` method instead"]
pub const unsafe fn from_bits_unchecked(bits: c_ushort) -> Self {
Self::from_bits_retain(bits)
}
}
bitflags! {
#[repr(transparent)]
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash, Ord, PartialOrd)]
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 */
}
}
impl FilterFlag {
/// Convert from underlying bit representation, preserving all
/// bits (even those not corresponding to a defined flag).
///
/// # Safety
///
/// The caller of the `bitflags!` macro can chose to allow or
/// disallow extra bits for their bitflags type.
///
/// The caller of `from_bits_unchecked()` has to ensure that
/// all bits correspond to a defined flag or that extra bits
/// are valid for this bitflags type.
#[deprecated = "use the safe `from_bits_retain` method instead"]
pub const unsafe fn from_bits_unchecked(bits: c_uint) -> Self {
Self::from_bits_retain(bits)
}
}
@@ -0,0 +1,107 @@
use bitflags::bitflags;
use libc::{c_uint, c_ushort};
#[allow(non_camel_case_types)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Ord, PartialOrd)]
#[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! {
#[repr(transparent)]
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash, Ord, PartialOrd)]
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;
}
}
impl EventFlag {
/// Convert from underlying bit representation, preserving all
/// bits (even those not corresponding to a defined flag).
///
/// # Safety
///
/// The caller of the `bitflags!` macro can chose to allow or
/// disallow extra bits for their bitflags type.
///
/// The caller of `from_bits_unchecked()` has to ensure that
/// all bits correspond to a defined flag or that extra bits
/// are valid for this bitflags type.
#[deprecated = "use the safe `from_bits_retain` method instead"]
pub const unsafe fn from_bits_unchecked(bits: c_ushort) -> Self {
Self::from_bits_retain(bits)
}
}
bitflags! {
#[repr(transparent)]
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash, Ord, PartialOrd)]
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;
}
}
impl FilterFlag {
/// Convert from underlying bit representation, preserving all
/// bits (even those not corresponding to a defined flag).
///
/// # Safety
///
/// The caller of the `bitflags!` macro can chose to allow or
/// disallow extra bits for their bitflags type.
///
/// The caller of `from_bits_unchecked()` has to ensure that
/// all bits correspond to a defined flag or that extra bits
/// are valid for this bitflags type.
#[deprecated = "use the safe `from_bits_retain` method instead"]
pub const unsafe fn from_bits_unchecked(bits: c_uint) -> Self {
Self::from_bits_retain(bits)
}
}
+125
View File
@@ -0,0 +1,125 @@
use bitflags::bitflags;
use libc::{c_uint, c_ushort};
#[allow(non_camel_case_types)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Ord, PartialOrd)]
#[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! {
#[repr(transparent)]
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash, Ord, PartialOrd)]
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;
}
}
impl EventFlag {
/// Convert from underlying bit representation, preserving all
/// bits (even those not corresponding to a defined flag).
///
/// # Safety
///
/// The caller of the `bitflags!` macro can chose to allow or
/// disallow extra bits for their bitflags type.
///
/// The caller of `from_bits_unchecked()` has to ensure that
/// all bits correspond to a defined flag or that extra bits
/// are valid for this bitflags type.
#[deprecated = "use the safe `from_bits_retain` method instead"]
pub const unsafe fn from_bits_unchecked(bits: c_ushort) -> Self {
Self::from_bits_retain(bits)
}
}
bitflags! {
#[repr(transparent)]
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash, Ord, PartialOrd)]
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;
}
}
impl FilterFlag {
/// Convert from underlying bit representation, preserving all
/// bits (even those not corresponding to a defined flag).
///
/// # Safety
///
/// The caller of the `bitflags!` macro can chose to allow or
/// disallow extra bits for their bitflags type.
///
/// The caller of `from_bits_unchecked()` has to ensure that
/// all bits correspond to a defined flag or that extra bits
/// are valid for this bitflags type.
#[deprecated = "use the safe `from_bits_retain` method instead"]
pub const unsafe fn from_bits_unchecked(bits: c_uint) -> Self {
Self::from_bits_retain(bits)
}
}
+24
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::*;
+95
View File
@@ -0,0 +1,95 @@
use bitflags::bitflags;
#[allow(non_camel_case_types)]
#[repr(u32)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Ord, PartialOrd)]
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! {
#[repr(transparent)]
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash, Ord, PartialOrd)]
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;
}
}
impl EventFlag {
/// Convert from underlying bit representation, preserving all
/// bits (even those not corresponding to a defined flag).
///
/// # Safety
///
/// The caller of the `bitflags!` macro can chose to allow or
/// disallow extra bits for their bitflags type.
///
/// The caller of `from_bits_unchecked()` has to ensure that
/// all bits correspond to a defined flag or that extra bits
/// are valid for this bitflags type.
#[deprecated = "use the safe `from_bits_retain` method instead"]
pub const unsafe fn from_bits_unchecked(bits: u32) -> Self {
Self::from_bits_retain(bits)
}
}
bitflags! {
#[repr(transparent)]
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash, Ord, PartialOrd)]
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;
}
}
impl FilterFlag {
/// Convert from underlying bit representation, preserving all
/// bits (even those not corresponding to a defined flag).
///
/// # Safety
///
/// The caller of the `bitflags!` macro can chose to allow or
/// disallow extra bits for their bitflags type.
///
/// The caller of `from_bits_unchecked()` has to ensure that
/// all bits correspond to a defined flag or that extra bits
/// are valid for this bitflags type.
#[deprecated = "use the safe `from_bits_retain` method instead"]
pub const unsafe fn from_bits_unchecked(bits: u32) -> Self {
Self::from_bits_retain(bits)
}
}
@@ -0,0 +1,96 @@
use bitflags::bitflags;
use libc::{c_uint, c_ushort};
#[allow(non_camel_case_types)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Ord, PartialOrd)]
#[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! {
#[repr(transparent)]
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash, Ord, PartialOrd)]
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;
}
}
impl EventFlag {
/// Convert from underlying bit representation, preserving all
/// bits (even those not corresponding to a defined flag).
///
/// # Safety
///
/// The caller of the `bitflags!` macro can chose to allow or
/// disallow extra bits for their bitflags type.
///
/// The caller of `from_bits_unchecked()` has to ensure that
/// all bits correspond to a defined flag or that extra bits
/// are valid for this bitflags type.
#[deprecated = "use the safe `from_bits_retain` method instead"]
pub const unsafe fn from_bits_unchecked(bits: c_ushort) -> Self {
Self::from_bits_retain(bits)
}
}
bitflags! {
#[repr(transparent)]
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash, Ord, PartialOrd)]
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;
}
}
impl FilterFlag {
/// Convert from underlying bit representation, preserving all
/// bits (even those not corresponding to a defined flag).
///
/// # Safety
///
/// The caller of the `bitflags!` macro can chose to allow or
/// disallow extra bits for their bitflags type.
///
/// The caller of `from_bits_unchecked()` has to ensure that
/// all bits correspond to a defined flag or that extra bits
/// are valid for this bitflags type.
#[deprecated = "use the safe `from_bits_retain` method instead"]
pub const unsafe fn from_bits_unchecked(bits: c_uint) -> Self {
Self::from_bits_retain(bits)
}
}
+136
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);
}
}
}