1# please insert nothing before this line: -*- mode: cperl; cperl-indent-level: 4; cperl-continued-statement-offset: 4; indent-tabs-mode: nil -*- 2# Licensed to the Apache Software Foundation (ASF) under one or more 3# contributor license agreements. See the NOTICE file distributed with 4# this work for additional information regarding copyright ownership. 5# The ASF licenses this file to You under the Apache License, Version 2.0 6# (the "License"); you may not use this file except in compliance with 7# the License. You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16# 17package ModPerl::Const; 18 19use DynaLoader (); 20 21our $VERSION = do { require mod_perl2; $mod_perl2::VERSION }; 22our @ISA = qw(DynaLoader); 23 24#dlopen("Const.so", RTDL_GLOBAL); 25#XXX: dl_dlopen.xs check isn't portable; works for hpux 26# - on aix this is dl_aix.xs, and depending on release, RTDL_GLOBAL is 27# available or not, e.g. 4.3 doesn't have it in the headers, while 28# 5.1 does have it 29# - from looking at ext/DynaLoader/dl_*.xs when 0x01 is used when it's 30# not supported perl issues a warning and passes the right flag to dlopen 31# - currently (patchlevel 18958) dl_aix.xs always issues a warning 32# even when RTDL_GLOBAL is available, patch submitted to p5p 33use Config (); 34use constant DL_GLOBAL => 35 ( $Config::Config{dlsrc} eq 'dl_dlopen.xs' && $^O ne 'openbsd' ) ? 0x01 : 0x0; 36sub dl_load_flags { DL_GLOBAL } 37 38#only bootstrap for use outside of mod_perl 39unless (defined &ModPerl::Const::compile) { 40 __PACKAGE__->bootstrap($VERSION); 41} 42 43sub import { 44 my $class = shift; 45 my $arg; 46 47 if ($_[0] and $_[0] =~ /^-compile/) { 48 $arg = shift; #just compile the constants subs, export nothing 49 } 50 51 $arg ||= scalar caller; #compile and export into caller's namespace 52 53 $class->compile($arg, @_ ? @_ : ':common'); 54} 55 561; 57