lcpfs 2026.1.102

LCP File System - A ZFS-inspired copy-on-write filesystem for Rust
// LCPFS: Platform Abstraction Layer
// PURPOSE: Isolate architecture-specific code for portability
// ARCHITECTURE: Compile-time feature selection via cfg attributes

//! Platform-specific implementations for LCPFS.
//!
//! This module provides portable abstractions over architecture-specific
//! functionality, primarily for entropy generation.
//!
//! # Supported Architectures
//!
//! - **x86_64**: Hardware RNG (RDRAND), timestamp counter (RDTSC), Linux syscalls
//! - **aarch64**: ARM64 CNTVCT (virtual counter), Linux getrandom syscall
//! - **fallback**: Software-only entropy (NOT cryptographically secure)
//!
//! # Usage
//!
//! ```rust,ignore
//! use lcpfs::arch::{fill_hardware_entropy, get_timestamp};
//!
//! let mut buf = [0u8; 32];
//! if fill_hardware_entropy(&mut buf).is_ok() {
//!     // Got hardware entropy
//! }
//!
//! let timestamp = get_timestamp();
//! ```

#[cfg(target_arch = "x86_64")]
mod x86_64;

#[cfg(target_arch = "aarch64")]
mod aarch64;

#[cfg(not(any(target_arch = "x86_64", target_arch = "aarch64")))]
mod fallback;

// Re-export platform-specific implementations under common names

#[cfg(target_arch = "x86_64")]
pub use x86_64::*;

#[cfg(target_arch = "aarch64")]
pub use aarch64::*;

#[cfg(not(any(target_arch = "x86_64", target_arch = "aarch64")))]
pub use fallback::*;

/// Error type for platform-specific operations
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ArchError {
    /// Hardware entropy source unavailable
    HardwareUnavailable,
    /// Operation failed
    OperationFailed,
    /// Feature not supported on this architecture
    Unsupported,
}