NAME
Hypersonic::JIT::Util - Utilities for JIT compilation in Hypersonic
SYNOPSIS
use Hypersonic::JIT::Util;
# Get cache directory
my $cache = Hypersonic::JIT::Util->cache_dir('socket');
# Returns: _hypersonic_cache/socket
# Compile standalone modules in parallel
Hypersonic::JIT::Util->compile_standalone_modules(parallel => 1);
# Add common includes to builder
Hypersonic::JIT::Util->add_standard_includes($builder, qw(socket threading));
# Detect library
my $ssl = Hypersonic::JIT::Util->detect_openssl();
if ($ssl->{available}) {
# Use $ssl->{cflags} and $ssl->{ldflags}
}
DESCRIPTION
This module provides common utilities for JIT compilation across Hypersonic modules:
Unified cache directory structure
Fork-based parallel compilation
Standard include patterns
Library detection (Alien → pkg-config → path search)
METHODS
cache_dir($subdir)
Returns the cache directory path. With $subdir, returns _hypersonic_cache/$subdir.
compile_standalone_modules(%opts)
Compiles all standalone modules (Socket, Response, Session, TLS).
Options:
- parallel => 1
-
Use fork for parallel compilation (default: 1)
- modules => \@list
-
Override list of modules to compile
can_fork()
Returns true if fork() is available on this platform.
add_standard_includes($builder, @features)
Adds standard C includes to the builder based on features: socket, threading, time, signal, unistd, fcntl
detect_library($name, %opts)
Detects a C library. Returns hashref with available, cflags, ldflags.
detect_openssl(), detect_zlib(), detect_nghttp2()
Convenience methods for common libraries.
has_c99()
Returns true if the compiler supports C99 features (inline keyword and for-loop variable declarations). Result is cached after first call.
if (Hypersonic::JIT::Util->has_c99()) {
$builder->line('static inline int fast_func(void) { return 1; }');
}
inline_keyword()
Returns 'inline' if C99 is supported, empty string otherwise.
my $inline = Hypersonic::JIT::Util->inline_keyword();
$builder->line("static $inline void my_func(void) { }");
AUTHOR
Hypersonic Contributors
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 563:
Non-ASCII character seen before =encoding in '→'. Assuming UTF-8