Skip to main content

types_darwin.go

types_darwin.go - Overview

This file provides type conversions and utility functions specific to Darwin (macOS) for the iomultiplexer package. It handles conversions between generic event and operation types and their Darwin-specific counterparts using the syscall package.

Detailed Documentation

Function: newTime

  • Purpose: Converts a time.Duration to a syscall.Timespec pointer, which is used in Darwin system calls for specifying timeouts.
  • Parameters:
    • t (time.Duration): The duration to convert.
  • Returns:
    • *syscall.Timespec: A pointer to a syscall.Timespec representing the duration. Returns nil if the duration is negative.

Function: (Event) toNative

  • Purpose: Converts a generic Event to a Darwin-specific syscall.Kevent_t struct.
  • Parameters:
    • e (Event): The generic event to convert.
    • flags (uint16): Flags to be set on the Kevent.
  • Returns:
    • syscall.Kevent_t: The Darwin-specific Kevent struct.

Function: newEvent

  • Purpose: Converts a Darwin-specific syscall.Kevent_t struct to a generic Event.
  • Parameters:
    • kEvent (syscall.Kevent_t): The Darwin-specific Kevent struct.
  • Returns:
    • Event: The generic event.

Function: (Operations) toNative

  • Purpose: Converts generic Operations (read/write) to a Darwin-specific filter type (int16).
  • Parameters:
    • op (Operations): The generic operations to convert.
  • Returns:
    • int16: The Darwin-specific filter type.

Function: newOperations

  • Purpose: Converts a Darwin-specific filter type (int16) to generic Operations (read/write).
  • Parameters:
    • filter (int16): The Darwin-specific filter type.
  • Returns:
    • Operations: The generic operations.

Code Examples

None.

Getting Started Relevance