Skip to content

Commit

Permalink
Merge pull request #2 from dimbleby/windows-sys
Browse files Browse the repository at this point in the history
winapi -> windows-sys
  • Loading branch information
dimbleby committed Oct 21, 2023
2 parents ed83e3c + e79ccae commit b62482b
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 37 deletions.
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: cargo
directory: /
schedule:
interval: monthly
- package-ecosystem: github-actions
directory: /
schedule:
interval: monthly
64 changes: 64 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]
schedule:
- cron: "0 3 1 * *"

jobs:
test:
name: Test
runs-on: ${{ matrix.os }}
strategy:
matrix:
build: [x86_64, x86_64-beta, x86_64-nightly, i686, macos, win64, win32]
include:
- build: x86_64
os: ubuntu-latest
rust: stable
target: x86_64-unknown-linux-gnu
- build: x86_64-beta
os: ubuntu-latest
rust: beta
target: x86_64-unknown-linux-gnu
- build: x86_64-nightly
os: ubuntu-latest
rust: nightly
target: x86_64-unknown-linux-gnu
- build: i686
os: ubuntu-latest
rust: stable
target: i686-unknown-linux-gnu
- build: macos
os: macos-latest
rust: stable
target: x86_64-apple-darwin
- build: win32
os: windows-latest
rust: stable
target: i686-pc-windows-msvc
- build: win64
os: windows-latest
rust: stable
target: x86_64-pc-windows-msvc
steps:
- uses: actions/checkout@v4
- name: Install Rust (rustup)
run: rustup update ${{ matrix.rust }} --no-self-update && rustup default ${{ matrix.rust }}
shell: bash
- run: rustup target add ${{ matrix.target }}
- run: cargo fmt -- --check
if: matrix.build == 'x86_64'
name: Check formatting
- run: cargo build
name: Build
- run: cargo test
name: Run tests
- run: |
cargo update -Z minimal-versions
cargo build
if: matrix.rust == 'nightly'
name: Check minimal versions
15 changes: 0 additions & 15 deletions .travis.yml

This file was deleted.

12 changes: 8 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
## 3.0.0 (21 October 2023)

- Switch from `winapi` to `windows-sys`

## 2.0.2 (7 Apr 2018)

* Bump libc dependency again (fixes minimal-versions build on OSX)
- Bump libc dependency again (fixes minimal-versions build on OSX)

## 2.0.1 (7 Apr 2018)

* Bump libc dependency (fixes minimal-versions build)
- Bump libc dependency (fixes minimal-versions build)

## 2.0.0 (4 Jan 2018)

* update to winapi 0.3
* start maintaining a CHANGELOG
- update to winapi 0.3
- start maintaining a CHANGELOG
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "c-types"
license = "MIT"
version = "2.0.2"
version = "3.0.0"
authors = ["David Hotham"]
description = """
Re-exports of cross-platform types, gathered from libc and winapi
Expand All @@ -15,4 +15,4 @@ keywords = ["libc", "winapi"]
libc = "0.2.21"

[target.'cfg(windows)'.dependencies]
winapi = { version = "0.3.3", features = ["winsock2", "ws2ipdef", "ws2tcpip"] }
windows-sys = { version = "0.48.0", features = ["Win32_Networking_WinSock"] }
34 changes: 18 additions & 16 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,34 +32,36 @@ mod unix {
pub type sockaddr_in6 = libc::sockaddr_in6;
pub type socklen_t = libc::socklen_t;

pub const AF_UNSPEC: i32 = libc::AF_UNSPEC;
pub const AF_INET: i32 = libc::AF_INET;
pub const AF_INET6: i32 = libc::AF_INET6;
pub type ADDRESS_FAMILY = libc::c_int;
pub const AF_UNSPEC: ADDRESS_FAMILY = libc::AF_UNSPEC;
pub const AF_INET: ADDRESS_FAMILY = libc::AF_INET;
pub const AF_INET6: ADDRESS_FAMILY = libc::AF_INET6;
}

#[cfg(windows)]
mod windows {
extern crate libc;
extern crate winapi;
extern crate windows_sys;

pub type fd_set = winapi::um::winsock2::fd_set;
pub type hostent = winapi::um::winsock2::hostent;
pub type in_addr = winapi::shared::inaddr::in_addr;
pub type in6_addr = winapi::shared::in6addr::in6_addr;
pub type fd_set = windows_sys::Win32::Networking::WinSock::FD_SET;
pub type hostent = windows_sys::Win32::Networking::WinSock::HOSTENT;
pub type in_addr = windows_sys::Win32::Networking::WinSock::IN_ADDR;
pub type in6_addr = windows_sys::Win32::Networking::WinSock::IN6_ADDR;
#[repr(C)]
pub struct iovec {
pub iov_base: *mut libc::c_void,
pub iov_len: libc::size_t,
}
pub type sa_family_t = winapi::shared::ws2def::ADDRESS_FAMILY;
pub type sockaddr = winapi::shared::ws2def::SOCKADDR;
pub type sockaddr_in = winapi::shared::ws2def::SOCKADDR_IN;
pub type sockaddr_in6 = winapi::shared::ws2ipdef::SOCKADDR_IN6_LH;
pub type socklen_t = winapi::um::ws2tcpip::socklen_t;
pub type sa_family_t = windows_sys::Win32::Networking::WinSock::sa_family_t;
pub type sockaddr = windows_sys::Win32::Networking::WinSock::SOCKADDR;
pub type sockaddr_in = windows_sys::Win32::Networking::WinSock::SOCKADDR_IN;
pub type sockaddr_in6 = windows_sys::Win32::Networking::WinSock::SOCKADDR_IN6;
pub type socklen_t = windows_sys::Win32::Networking::WinSock::socklen_t;

pub const AF_UNSPEC: i32 = winapi::shared::ws2def::AF_UNSPEC;
pub const AF_INET: i32 = winapi::shared::ws2def::AF_INET;
pub const AF_INET6: i32 = winapi::shared::ws2def::AF_INET6;
pub type ADDRESS_FAMILY = windows_sys::Win32::Networking::WinSock::ADDRESS_FAMILY;
pub const AF_UNSPEC: ADDRESS_FAMILY = windows_sys::Win32::Networking::WinSock::AF_UNSPEC;
pub const AF_INET: ADDRESS_FAMILY = windows_sys::Win32::Networking::WinSock::AF_INET;
pub const AF_INET6: ADDRESS_FAMILY = windows_sys::Win32::Networking::WinSock::AF_INET6;
}

#[cfg(unix)]
Expand Down

0 comments on commit b62482b

Please sign in to comment.