{"id":35882957,"url":"https://github.com/coenttb/swift-kernel-primitives","last_synced_at":"2026-01-22T06:42:53.613Z","repository":{"id":332416803,"uuid":"1129915493","full_name":"coenttb/swift-kernel-primitives","owner":"coenttb","description":"The Swift kernel primitives library built on swift-standards.","archived":false,"fork":false,"pushed_at":"2026-01-08T20:41:10.000Z","size":334,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-13T20:40:46.272Z","etag":null,"topics":["cross-platform","io","kernel","low-level","swift","swift-package","systems-programming"],"latest_commit_sha":null,"homepage":"https://coenttb.com","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/coenttb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":["coenttb"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"lfx_crowdfunding":null,"polar":null,"buy_me_a_coffee":null,"thanks_dev":null,"custom":null}},"created_at":"2026-01-07T19:07:11.000Z","updated_at":"2026-01-08T21:19:20.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/coenttb/swift-kernel-primitives","commit_stats":null,"previous_names":["coenttb/swift-kernel-primitives"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/coenttb/swift-kernel-primitives","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coenttb%2Fswift-kernel-primitives","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coenttb%2Fswift-kernel-primitives/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coenttb%2Fswift-kernel-primitives/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coenttb%2Fswift-kernel-primitives/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coenttb","download_url":"https://codeload.github.com/coenttb/swift-kernel-primitives/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coenttb%2Fswift-kernel-primitives/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28657108,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-22T01:17:37.254Z","status":"online","status_checked_at":"2026-01-22T02:00:07.137Z","response_time":144,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cross-platform","io","kernel","low-level","swift","swift-package","systems-programming"],"created_at":"2026-01-08T19:20:10.610Z","updated_at":"2026-01-22T06:42:53.606Z","avatar_url":"https://github.com/coenttb.png","language":"Swift","funding_links":["https://github.com/sponsors/coenttb"],"categories":[],"sub_categories":[],"readme":"# Kernel Primitives\n\n![Development Status](https://img.shields.io/badge/status-active--development-blue.svg)\n[![CI](https://github.com/coenttb/swift-kernel-primitives/workflows/CI/badge.svg)](https://github.com/coenttb/swift-kernel-primitives/actions/workflows/ci.yml)\n\nType-safe, policy-free wrappers around platform kernel syscalls for Swift. Provides low-level I/O, memory mapping, threading primitives, and file operations with typed throws and full Sendable compliance.\n\n---\n\n## Key Features\n\n- **Typed throws end-to-end** – Every error type is statically known; no `any Error` escapes the API surface\n- **Swift 6 strict concurrency** – Full `Sendable` compliance with documented thread-safety guarantees\n- **Cross-platform** – Unified API across macOS, Linux, and Windows with platform-specific optimizations\n- **Policy-free design** – Raw syscall wrappers without opinions on scheduling, buffering, or lifecycle\n- **Direct I/O support** – Aligned, unbuffered I/O for databases and high-performance applications\n- **Memory mapping** – `mmap`/`VirtualAlloc` with page protection and synchronization controls\n- **Zero Foundation dependency** – Pure Swift with minimal platform imports\n\n---\n\n## Installation\n\n### Package.swift dependency\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/coenttb/swift-kernel-primitives.git\", from: \"0.1.0\")\n]\n```\n\n### Target dependency\n\n```swift\n.target(\n    name: \"YourTarget\",\n    dependencies: [\n        .product(name: \"Kernel Primitives\", package: \"swift-kernel-primitives\")\n    ]\n)\n```\n\n### Requirements\n\n- Swift 6.2+\n- macOS 26+ / iOS 26+ / tvOS 26+ / watchOS 26+ / Linux / Windows\n\n---\n\n## Quick Start\n\n```swift\nimport Kernel_Primitives\n\n// Open a file\nlet descriptor = try Kernel.File.Open.open(\n    path: Kernel.Path(\"/tmp/data.txt\"),\n    mode: [.read, .write],\n    options: [.create],\n    permissions: .ownerReadWrite\n)\ndefer { try? Kernel.Close.close(descriptor) }\n\n// Write data\nlet message = \"Hello, kernel!\"\ntry message.utf8.withContiguousStorageIfAvailable { bytes in\n    _ = try Kernel.IO.Write.write(descriptor, from: UnsafeRawBufferPointer(bytes))\n}\n\n// Read file stats\nlet stats = try Kernel.File.Stats.get(descriptor: descriptor)\nprint(\"Size: \\(stats.size) bytes, Type: \\(stats.type)\")\n```\n\n---\n\n## Architecture\n\n| Type | Description |\n|------|-------------|\n| `Kernel.Descriptor` | Platform file descriptor (`int` / `HANDLE`) |\n| `Kernel.File.Open` | File open operations with mode, options, permissions |\n| `Kernel.File.Handle` | RAII wrapper with Direct I/O support and alignment tracking |\n| `Kernel.File.Stats` | Cross-platform file metadata (size, type, times, permissions) |\n| `Kernel.IO.Read` | Positional and sequential read operations |\n| `Kernel.IO.Write` | Positional and sequential write operations |\n| `Kernel.Memory.Map` | Memory-mapped I/O with protection and sync flags |\n| `Kernel.Memory.Lock` | Page locking (`mlock` / `VirtualLock`) |\n| `Kernel.Pipe` | Anonymous pipe creation |\n| `Kernel.Socket` | Socket operations (see swift-posix for socket pairs) |\n| `Kernel.Thread.Mutex` | Low-level mutex |\n| `Kernel.Lock` | File locking |\n| `Kernel.Copy` | Kernel-accelerated file copy with CoW support |\n| `Kernel.Device` | Device identifier (see swift-posix for major/minor) |\n\n\u003e **Note:** POSIX-specific APIs (`mlockall`, `socketpair`, device major/minor) are in [swift-posix](https://github.com/coenttb/swift-posix).\n\n---\n\n## Platform Support\n\n| Platform         | CI  | Status       |\n|------------------|-----|--------------|\n| macOS            | ✅  | Full support |\n| Linux            | ✅  | Full support |\n| Windows          | ✅  | Full support |\n| iOS/tvOS/watchOS | —   | Supported    |\n\n---\n\n## Related Packages\n\n### Dependencies\n\n- [swift-standards](https://github.com/swift-standards/swift-standards): Binary data types and standards\n\n### Used By\n\n- [swift-kernel](https://github.com/coenttb/swift-kernel): Higher-level kernel abstractions\n- [swift-io](https://github.com/coenttb/swift-io): Async I/O executor built on kernel primitives\n- [swift-file-system](https://github.com/coenttb/swift-file-system): File system operations\n\n---\n\n## License\n\nThis project is licensed under the Apache License v2.0. See [LICENSE.md](LICENSE.md) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoenttb%2Fswift-kernel-primitives","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoenttb%2Fswift-kernel-primitives","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoenttb%2Fswift-kernel-primitives/lists"}