Ada scheduling in EDF - scheduled-tasks

For some reason this EDF example doesn't compile. I'm using GNAT I tried it in Windows 8.1, Debian no result.
with Ada.Real_Time, ada.Task_Identification,ada.Dispatching.EDF; use Ada.Real_Time, ada.Task_Identification,ada.Dispatching.EDF;
Procedure exemple_ordon is
Task tache_Periodique;
Task body tache_Periodique is
Echeance: Time_Span := Milliseconds(30); heure: Time;
Begin
heure:= Clock; Set_Deadline(Clock + Echeance);
Loop
heure := heure + Echeance;Delay_Until_And_Set_Deadline(heure,Echeance);
end loop;
End tache_Periodique;
Begin Null; End exemple_ordon ;
The error message:
gnatmake -d -PC:\Users\Awk\default.gpr exemple_ordon.adb
gcc -c -g -O2 -I- -gnatA C:\Users\Awk\exemple_ordon.adb
Edf is not supported in this configuration
compilation abandoned
gnatmake: "C:\Users\Awk\exemple_ordon.adb" compilation error

The message Edf is not supported in this configuration tells the story!
I don’t have access to any supported version of GNAT, but the file a-disedf.ads (the spec of Ada.Dispatching.EDF) in FSF GCC 4.9.0 contains the comment
-- This unit is not implemented in typical GNAT implementations that lie on
-- top of operating systems, because it is infeasible to implement in such
-- environments.
-- If a target environment provides appropriate support for this package,
-- then the Unimplemented_Unit pragma should be removed from this spec and
-- an appropriate body provided.
so it’s possible that AdaCore may provide an implementation for some of the more real-time targets (e.g. VxWorks) for their paying customers.
Do you have access to AdaCore’s academic program (GAP)?
If you really need EDF scheduling, Concurrency in Ada by Burns and Wellings has an example (I have the paperback second edition); you can pick it up cheaply at AbeBooks.
If you ‘just’ need information about general tasking, there are several sources listed at the Ada Information Clearinghouse.
Many people developing high-integrity real time software in Ada use the Ravenscar Profile.

Related

OpenCobol & PostgreSQL on Windows with Visual Studio

I'm currently facing a problem with this team of 4.
Using binaries I downloaded on kiska's site. I'm able to compile cobol to C and run it with cobcrun or compile it to an executable. However I can 't get opencobol to find the postgres commands.
Here is the strat of my cobol script :
identification division.
program-id. pgcob.
data division.
working-storage section.
01 pgconn usage pointer.
01 pgres usage pointer.
01 resptr usage pointer.
01 resstr pic x(80) based.
01 result usage binary-long.
01 answer pic x(80).
procedure division.
display "Before connect:" pgconn end-display
call "PQconnectdb" using
by reference "dbname = postgres" & x"00"
by reference "host = 10.37.180.146" & "00"
returning pgconn
end-call
...
the call PQconnectdb fail with module ont found : PQconnectdb
I noticed that if i rename the libpq.dll the error message change to can't find entry point. So at least I'm sure it can get my dll.
After digging into the code of the call method of the libcob library. I found it it was possible to pre load some dll using an environment variable COB_PRE_LOAD but sitll no results.
Here is what look the script to compile the cobol :
call "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\amd64\vcvarsamd64.bat"
set COB_CONFIG_DIR=C:\OpenCobol\config
set COB_COPY_DIR=C:\OpenCobol\Copy
set COB_LIBS=%COB_LIBS% c:\OpenCobol\libpq.lib
set COB_LIBRARY_PATH=C:\OpenCobol\bin
set COB_PRE_LOAD=C:\OpenCobol\libpq.dll
#echo on
cobc -info
cobc -free -o pgcob -L:"C:\OpenCobol" -llibpq.lib test_cobol\postgres.cob
call cobcrun pgcob
I don't see anything missing, I'm using the 64-bit binaries from kiska's site and use the 64-bit cl.exe from Visual Studio, Postgres is a 64 bit version too (checked with dependencyChecker).
I even tryed to compile the generated C from Visual Studio, same result, but I may miss something, I'm pretty rotten in C and never really had to manage DLL or use Visual Studio.
What am I missing ?
COB_PRE_LOAD doesn't take any path or extension, see the short documentation for the available runtime configurations. I guess
set COB_LIBRARY_PATH=C:\OpenCobol\bin;C:\OpenCobol
set COB_PRE_LOAD=libpq
Will work. You can omit the C:\OpenCobol\bin if you did not placed any additional executables there.
If it doesn't work (even if it does) I'd try to get the C functions resolved at compile time. Either use
CALL STATIC "PQconnectdb" using ...
or an appropriate CALL-CONVENTION or leave the program as-is and use
cobc -free -o pgcob -L"C:\OpenCobol" -llibpq -K PQconnectdb test_cobol\postgres.cob
From cobc --help:
-K generate CALL to <entry> as static
In general: the binaries from kiska.net are quite outdated. I highly suggest getting newer ones from the official download site or ideally build them on your own from source, see the documentation for building GnuCOBOL with VisualStudio.

How to print preprocessor macros under Sun Studio?

I'm working under Sun Studio 12.3 on SunOS 5.11 (Solaris 11.3). I need to see the macros that Sun Studio defines to fix a bug report taken under the suite. This is similar to Solaris and Preprocessor Macros, but the cited question uses GCC and its preprocessor; and not Sun Studio's preprocessor.
I've run CC -flags but I don't see an option similar to GCC's cpp -dM or g++ -dM -E - </dev/null. CC does have a -E, but its fairly anemic and does not print any preprocessor definitions:
$ echo $CXX
/opt/solarisstudio12.3/bin/CC
$ $CXX -E /dev/null
#1 "/dev/null"
Using a real test file produces a similar result - preprocessor macros are missing:
$ $CXX -E test.cxx | grep __cplusplus
$
I also found the discussion of preprocessor macros in the Sun Studio manual at 2.5.3 Predefined Names. Table A-2 is OK, but its mostly anemic, too. Its missing basics like __cplusplus, and its missing other defines like _RWSTD_NO_CLASS_PARTIAL_SPEC.
How do I print preprocessor macros under Sun Studio?
$ /opt/solarisstudio12.3/bin/CC -flags
______________________________________________________________________________
Items within [ ] are optional. Items within < > are variable parameters.
Bar | indicates choice of literal values.
______________________________________________________________________________
-# Verbose mode
-### Show compiler commands built by driver, no compilation
-B[static|dynamic] Specify dynamic or static binding
-D<name[=token]> Associate name with token as if by #define
-E Compile source through preprocessor only, output to stdout
-G Build a dynamic shared library
-H Print path name of each file included during compilation
-I<dir> Add <dir> to preprocessor #include file search path
-KPIC Compile position independent code with 32-bit addresses
-Kpic Compile position independent code
-L<dir> Pass to linker to add <dir> to the library search path
-M<file> Pass <file> mapfile to linker
-O Use default optimization level (-xO3)
-O<n> Same as -xO<n>
-P Compile source through preprocessor only, output to .i file
-PIC Same as -KPIC
-Qoption <prog> <o>[,<o>...] Pass options list <o> to compilation phase <prog>
-R<dir[:dir]> Build runtime search path list into executable
-S Compile and only generate assembly code (.s)
-U<name> Delete initial definition of preprocessor symbol <name>
-V Report version number of each compilation phase
-W<c>,<arg> Pass <arg> to specified component <c> (a,d,h,i,l,m,p,u,0,2)
-Xlinker <arg> Pass <arg> to linker
-Xm Support dollar character in C++ identifiers
-Y<c>,<dir> Specify <dir> for location of component <c> (a,l,m,p,0,h,i,u)
-YA,<dir> Change default directory searched for components
-YI,<dir> Change default directory searched for include files
-YP,<dir> Change default directory for finding libraries files
-YS,<dir> Change default directory for startup object files
-c Compile only - produce .o files, suppress linking
-compat=5 Standard mode; accept source code that conforms to the C++ standard (default mode)
-compat=g G++ compatibility mode; accept g++ source code and generate g++ compatible object code
+d Do not expand inline functions
-dalign Ignored
-d{n|y} Dynamic [-dy] or static [-dn] option to linker
-dryrun Show compiler commands built by driver, no compilation
-e<arg> Passed to linker
-erroff[=<tags>] Suppress warnings specified by tags; <tags>={%none, %all, <tag list>}
-errtags[={yes|no}] Display messages with tags
-errwarn[=<tags>] Treats warnings specified by tags as errors; <tags>={%none, %all, <tag list>}
-fPIC Same as -KPIC
-fast Optimize using a selection of options
-features=<a>[,<a>] Enable/disable various C++ language features
-filt[=<a>[,<a>]] Control the filtering of both linker and compiler error messages;
<a>={errors,names,returns,stdlib}
-flags Show this summary of compiler options
-flagsrc=<f> Accept command options from file <f>
-fnonstd Initialize floating-point hardware to non-standard preferences
-fns[={yes|no}] Select non-standard floating point mode
-fpic Same as -Kpic
-fprecision=<a> Set FP rounding precision mode; <a>={single|double|extended}
-fround=<r> Select the IEEE rounding mode in effect at startup
-fsimple[=<n>] Select floating-point optimization preferences <n>
-fstore Force floating pt. values to target precision on assignment
-ftrap=<t> Select floating-point trapping mode in effect at startup
-g Compile for debugging
-g0 Compile for debugging by dbx but allow inlining
-g3 Compile for debugging by dbx including macros.
-h <name> Assign <name> to generated dynamic shared library
-help Same as -xhelp=flags
-i Passed to linker to ignore any LD_LIBRARY_PATH setting
-include <file> Include the contents of <file> before other files
-inline=<v> Attempt inlining of specified user routines; <v>={%auto,<func>,no%<func>}
-instances=<a> Control the link attributes of template instantiations;
<a>={static|global|extern|explicit|semiexplicit}
-instlib=<library> Inhibit generation of instances already in <library>
-keeptmp Keep temporary files created during compilation
-l<name> Link with library lib<name>.a or lib<name>.so
-libmieee Same as -xlibmieee
-libmil Same as -xlibmil
-library=<a>[,<a>] Incorporates specified CC-provided libraries into compilation and linking
-m32 Set 32-bit addressing model
-m64 Set 64-bit addressing model
-mc Remove duplicate strings from .comment section of output files
-migration Show where to get information about migrating from C++ 4.2
-mr Remove all strings from .comment section of output files
-mr,"string" Remove all strings and append "string" to .comment section
-mt[={yes|no}] Specify options needed when compiling multi-threaded code
-native Optimize for the host system (-xtarget=native)
-noex Same as -features=no%except
-nofstore Do not force floating pt. values to target precision on assignment
-o <outputfile> Set name of output file to <outputfile>
-p Compile for profiling with prof
+p Ignore non-standard preprocessor asserts
-pg Compile for profiling with gprof
-pic Same as -Kpic
-qp Compile for profiling with prof
-s Strip symbol table from the executable file
-shared Same as -G
-staticlib=<a>[,<a>] Force linkage of specified libraries to be static
-sync_stdio[={yes|no}] Controls synchronization of the I/O libraries
-temp=<path> Use <path> as directory for temporary files
-template=<a>[,<a>] Enable/disable various template options;
<a>={wholeclass,extdef,geninlinefuncs}
-time Same as -xtime
-traceback[=<a>[,<a>]] Provide stack traceback for the abnormal termination by signals; <a>={%none|common|<signal>}
-unroll=<n> Enable unrolling loops <n> times where possible
-v Same as -verbose=diags
-verbose=<a>[,<a>] Control verbosity during compilation; <a>={template,diags,version}
-w Suppress compiler warning messages
+w Print warnings about additional questionable constructs
+w2 Emit warnings for code with additional portability problems
-xF[=<a>[,<a>]] Compile for later mapfile reordering and data fragmentation
-xM Generate makefile dependencies
-xM1 Generate makefile dependencies, but exclude /usr/include
-xMD Generate makefile dependencies and compile at once
-xMMD Generate makefile dependencies like -xMD, but excluding standard headers
-xMF <file> Specify output <file> for makefile dependencies dump
-xMerge Merge data segment into text segment
-xO<n> Generate optimized code; <n>={1|2|3|4|5}
-xaddr32[={yes|no}] Generate binaries assuming the associated process is restricted to the lower 32bit address space
-xalias_level[=<a>] Enable optimizations based on the specified alias_level;
<a>={any|simple|compatible}
-xanalyze=code Generate static analysis information for the code analyzer
-xannotate[={yes|no}] Annotate binaries for optimization and analysis
-xar Create archive library with instantiated templates
-xarch=<a> Specify target architecture instruction set
-xautopar Enable automatic loop parallelization
-xbuiltin[=<a>] Inline system functions and intrinsics when beneficial;
<a>={%none|%default|%all}
-xcache=<t> Define cache properties for use by optimizer
-xchar[=<a>] Treat type char as signed (s) or unsigned (u);
<a>={s|signed|u|unsigned}
-xcheck[=<a>[,<a>]] Generate runtime checks for error condition;
<a>={stkovf,init_local}
-xchip=<a> Specify the target processor for use by the optimizer
-xcode=<a> Generate different code for forming addresses; <a>={pic13|pic32}
-xdebugformat=<a> Selects the format of debugging information; <a>={stabs|dwarf}
-xdepend[={yes|no}] Analyze loops for data dependencies
-xdumpmacros[=<a>[,<a>]] Prints macro definitions on the standard error output;
<a>={defs,undefs,use,loc,conds,sys}
-xdryrun The same as -###
-xe Perform only syntax/semantic checking, no code generation
-xhelp=<a> Display on-line help information; <a>={flags|readme}
-xia Enable interval arithmetic
-xinline=<v> Attempt inlining of specified user routines; <v>={%auto,<func>,no%<func>}
-xinstrument=[no_]datarace Enable/disable instrumentation for race detection tool
-xipo[=<n>] Enable optimization and inlining across source files; <n>={0|1|2}
-xipo_archive=<a> Enable crossfile optimization including archive files;
<a>={none|readonly|writeback}
-xivdep[=<a>] Ignore loop-carried dependences on array references in a loop; <a>={loop|loop_any|back|back_any|none}
-xjobs=<n> Maximum number of components compiler will fork in parallel
-xkeepframe[=<v>] Do not optimize stack frame of specified user routine; <v>={%all|%none|[no%]<func>}
-xlang=<a>[,<a>] The set of languages used in the program; <a>={f90,f95,c99}
-xldscope=<a> Indicates the appropriate linker scoping within the source program;
<a>={global|symbolic|hidden}
-xlibmieee Force IEEE 754 return values for math routines in exceptional cases
-xlibmil Inline selected libm math routines for optimization
-xlibmopt Link with optimized math library
-xlic_lib=sunperf (Obsolete) Use -library=sunperf instead
-xloopinfo Show loops that parallelized
-xmaxopt=[off,1,2,3,4,5] Maximum optimization level allowed on #pragma opt
-xmodel=<a> Specify memory model for 64-bit programs;
<a>={small|kernel|medium}
-xnolib Do not link with default system libraries
-xnolibmil Cancel -xlibmil on command line
-xnolibmopt Cancel -xlibmopt on command line
-xnorunpath Do not build a runtime search path into the executable
-xopenmp[=<a>] Enable OpenMP language extension; <a>={none|noopt|parallel}
-xpagesize=<a> Controls the preferred page size for the stack and for the heap; <a>={4K|2M|4M|1G|default}
-xpagesize_heap=<a> Controls the preferred page size for the heap; <a>={4K|2M|4M|1G|default}
-xpagesize_stack=<a> Controls the preferred page size for the stack; <a>={4K|2M|4M|1G|default}
-xpch=<t> Enable precompiled headers. Collect data for, or use existing, PCH file; <t>={auto|autofirst|{collect,use}:<file>[.cpch]}
-xpchstop=<file> Specified include file marks end of initial common sequence of pre-processing directives for precompiled headers
-xpec[={yes|no}] Generate a PEC binary
-xpg Compile for profiling with gprof
-xport64[=<a>] Enable extra checking for code ported from 32-bit to 64-bit platforms;
<a>={no|implicit|full}
-xprefetch[=<p>] Specify instruction prefetch; <p>={auto,no%auto,explicit,no%explicit}
-xprefetch_auto_type=<a> Specify automatic indirect prefetch insertion for loops;
<a>={indirect_array_access}
-xprefetch_level[=<n>] Controls the aggressiveness of the -xprefetch=auto option; <n>={1|2|3}
-xprofile=<t> Collect data for a profile or use a profile to optimize; <t>={{collect,use}[:<path>],tcov}
-xprofile_ircache[=<t>] Path to intermediate file cache used with -xprofile option
-xreduction Recognize reduction operations in parallelized loops
-xregs=<a>[,<a>] Specify the usage of optional registers; <a>={frameptr}
-xrestrict[=<f>] Treat pointer valued function parameters as restricted; <f>={%none,%all,<function-name list>}
-xs Allow debugging without object (.o) files
-xspace Do not do optimizations that increase code size
-xtarget=<a> Specify target system for optimization
-xtemp=<dir> Set directory for temporary files to <dir>
-xthreadvar[=<a>] Control code generation for thread variables; <a>={dynamic}
-xtime[=<a>] Report the execution time for each compilation phase; <a>={1|2|3}
-xtrigraphs[={yes|no}] Enable|disable trigraph translation
-xunroll=<n> Enable unrolling loops <n> times where possible
-xustr=<a> Recognize sixteen-bit string literals; <a>={ascii_utf16_ushort|no}
-xvector[=<a>[,<a>]] Automatic generation of calls to the vector library functions and/or the generation of the SIMD instructions
-xvpara Verbose parallelization warnings
-xwe Convert all warnings to errors
Suffix 'a' Object library
Suffix 'il' Inline template file
Suffix 'o' Object file
Suffix 'so' Shared object
Suffix 's' Assembler source
Suffix 'S' Assembler source for cpp
Suffix 'c' C++ source
Suffix 'cc' C++ source
Suffix 'cxx' C++ source
Suffix 'cpp' C++ source
Suffix 'C' C++ source
Suffix 'c++' C++ source
Suffix 'i' C++ source after preprocessing
Suffix 'err' ld error file
Suffix 'd' Build dependencies file
Use the -xdumpmacros option.
Per the Solaris Studio 12.4 C User's Guide:
B.2.105 -xdumpmacros[=value[,value...]]
Use this option when you want to see how macros are behaving in your
program. This option provides information such as macro defines,
undefines, and instances of usage. It prints output to the standard
error (stderr), based on the order in which macros are processed.
The -xdumpmacros option is in effect through the end of the file or
until it is overridden by the dumpmacros or end_dumpmacros pragma. See
dumpmacros.
The following table lists the valid arguments for value. The prefix
no% disables the associated value.
...
cc -E -xdumpmacros /dev/null produces this output:
#define __LINE__
#define __FILE__
#define __STDC__ 0
#define __STDC_VERSION__ 199409L
#define __DATE__ "Jun 9 2016"
#define __TIME__ "09:09:48"
#define __STDC_IEC_559__ 1
#define __STDC_IEC_559_COMPLEX__ 1
#define __STDC_HOSTED__ 1
#define __SunOS_5_11 1
#define __SUNPRO_C 0x5120
#define __unix 1
#define __SVR4 1
#define __sun 1
#define __SunOS 1
#define __i386 1
#define __BUILTIN_VA_ARG_INCR 1
#define __C99FEATURES__ 1
#define __PRAGMA_REDEFINE_EXTNAME 1
#define unix 1
#define sun 1
#define i386 1
#define __RESTRICT 1
#define __FLT_EVAL_METHOD__ - 1
#define __SUN_PREFETCH 1
#define __NOVECTORSIZE__ 1
# 1 "/dev/null"
#ident "acomp: Sun C 5.12 SunOS_i386 2011/11/16"

Testing for LibreSSL in a Perl build script

I released Net::NSCAng::Client a while ago and am getting a lot of test failures on OpenBSD. The reason for that is that the NSCAng protocol uses OpenSSL in preshared-key mode (RFC4279), something the folks at LibreSSL (default on OpenBSD now) have ripped out. However, they seem to have been hell-bent on doing this the most intransparent way: the include files have all the functions defined, just the shared library is missing the corresponding symbols, so compilation works fine but the tests fail.
There is a compatibility package on OpenBSD called eopenssl, and by testing for this first in Makefile.PL (using ExtUtils::PkgConfig) I can make it work if the compatibility library is installed. If it isn't, things still fail.
I could check for the CPP symbol OPENSSL_NO_PSK, but as the includes always come from LibreSSL, this fails even if linking with eopenssl would work fine. The only idea I have left is to try and have a test program run as part of the compilation phase as autoconf does it. Is that even possible with ExtUtils::MakeMaker (or something else -- I wouldn't mind switching the build system if necessary)?
It's easy to write feature tests with Devel::CheckLib. Something like the following can be used to check for the presence of function your_func (in Makefile.PL):
my $your_func_exists = check_lib(
header => 'your_header.h',
function => 'return your_func ? 1 : 0;',
);
If you simply want to abort compilation if the function is missing:
check_lib(
...
) or warn('your_func is missing'), exit;
Exiting with 0 should avoid a CPAN Tester's 'FAIL' report.

DBD::Informix connection issues

I'm having somewhat weird problem with DBD::Informix. If I run a simple script like that:
use DBI;
my $dbh = DBI->connect_cached('dbi:Informix:database', '', '');
my $sth = $dbh->prepare('select foo from bar');
...
It works all right. But if I try to do exactly the same from a test script it fails with the following message:
SQL: -25588: The appl process cannot connect to the database server cms_ol.
ISAM: 22: Invalid argument
The only difference I see is that test script is quite heavy on module usage; it is based on Test::More and loads a lot of submodules that are to be tested.
Turning on DBI trace does not provide anything useful (for me, at least). Simple script runs along just fine:
DBI 1.616-nothread default trace level set to 0x0/1 (pid 9685 pi 0) at test_ifx.pl line 6
Note: perl is running without the recommended perl -w option
-> DBI->connect(dbi:Informix:cms#cms_ol, , ****, HASH(0x13fad0))
-> DBI->install_driver(Informix) for solaris perl=5.008009 pid=9685 ruid=106 euid=106
install_driver: DBD::Informix version 2011.0612 loaded from /cms/webdash/lib/arch/DBD/Informix.pm
<- install_driver= DBI::dr=HASH(0x1c8070)
!! warn: 0 CLEARED by call to connect method
-->> DBD::Informix::dbd_ix_db_connect()
CONNECT TO 'cms#cms_ol' - no user info
-->> DBD::Informix::dbd_ix_db_check_for_autocommit()
... and the only difference in trace of the problematic script I see is that it just fails:
DBI 1.616-nothread default trace level set to 0x0/1 (pid 9687 pi 0) at 22_report.t line 5 via 22_report.t line 6
Note: perl is running without the recommended perl -w option
-> DBI->connect_cached(dbi:Informix:cms, , ****)
-> DBI->install_driver(Informix) for solaris perl=5.008009 pid=9687 ruid=106 euid=106
install_driver: DBD::Informix version 2011.0612 loaded from /cms/webdash/lib/arch/DBD/Informix.pm
<- install_driver= DBI::dr=HASH(0xb619bc)
!! warn: 0 CLEARED by call to connect_cached method
-->> DBD::Informix::dbd_ix_db_connect()
CONNECT TO 'cms' - no user info
***ERROR***
SQL: -25588: The appl process cannot connect to the database server cms_ol.
ISAM: 22: Invalid argument
<<-- dbd_ix_db_connect (**ERROR-1**)
<<-- DBD::Informix::dbd_ix_db_connect()
I'm running custom Perl 5.8.9 build in Solaris 9, with latest DBI and DBD::Informix versions, against Informix IDS 9.40UC.
Update: If I try to be a smartass and put a block like that at the top of the heavy test script:
use DBI;
BEGIN { my $dbh = DBI->connect_cached( ... ); print "Connected!\n" if $dbh; }
... it prints like this:
Connected!
Out of memory!
Callback called exit.
END failed--call queue aborted at t/22_report.t line 20.
Callback called exit at t/22_report.t line 20.
BEGIN failed--compilation aborted at t/22_report.t line 24.
My guess is that DBD::Informix conflicts with some of the modules loaded after the connection is made. But which one? That's the question...
Another update: It appears that the above trick does something unwieldy. I tried to load all the modules explicitly by replacing 'use Module' with 'require Module; Module->import'. Pure Perl modules are OK but whenever XS module using XSLoader appears, Perl goes boom with friendly 'Out of memory' message. And if I move Informix connection below module initialization, it works all right - except DBD::Informix fails with the same -25588 error. Boomer. I'm at loss. :(
Another another update: I tried to run the same script with standard Perl 5.6.1 shipped with Solaris 9, using DBI 1.601 (the latest that would compile with Perl 5.6) and DBD::Informix 2011.0612. Same thing, so it's not custom Perl giving me trouble.
I can also add that the test module in question was prototyped using DBD::SQLite and fully works. It is the final test with DBD::Informix that is failing... As usual. :/
Workaround: following e-mail discussion with Jonathan, a workaround was found: addition of streams-based 'onipcstr' connection to Informix server allowed DBD::Informix to connect. Apparently, some XS modules interfere with default shmem-based connection method, although the culprit is unknown at the moment.
Further discussion
Custom-built Perl is, in my experience, easier than the system Perl. I never modify the system's Perl installation (I don't want to break it) so I always build my own.
You appear to have:
Solaris 9 (SPARC?)
Perl 5.8.9
DBI 1.616
DBD::Informix 2011.0612
ESQL/C (CSDK) 2.81
Informix Dynamic Server 9.40
We don't have the detailed sub-version of ESQL/C and IDS (2.81.UC2, 9.40.UC5, or whatever). There's a hint that you are using a 32-bit version of IDS, so probably everything is 32-bit. You are probably aware that 9.40 is no longer supported by IBM (and, indeed, its successor version 10.00 is also out of support). However, superficially, none of that should matter very much. The failing t91lvarchar.t is not a big issue.
Can you run the connect in working and non-working modes with DBI_TRACE=9 set in the environment.
If the trace for the connect operation is too voluminous to go into an update to the question, we'd better take this off-line to the DBD::Informix support channels (that's me, but by email).
The 'ISAM' error of 22 (Invalid argument) is puzzling. I'm curious about what is in your sqlhosts file for this server - the entry for cms_ol specifically. I'm not sure it will reveal anything, not least because you say the sample ESQL/C below (in the 'First hypothesis' section) works OK, and sometimes the Perl connects and sometimes it does not.
I wonder if there is a name conflict somewhere between functions in the shared libraries? That sort of thing will be hell to track.
First hypothesis
Further information received shows that this was not the crucial distinction.
The difference appears to be:
Works: CONNECT TO 'cms#cms_ol' - no user info
Fails: CONNECT TO 'cms' - no user info
The tricky part to explain is why the second fails, especially as the error goes on to mention cms_ol.
The workaround is to specify the server name in the connect string:
DBI->connect(dbi:Informix:cms#cms_ol, , ****, HASH(0x13fad0))
DBI->connect_cached(dbi:Informix:cms, , ****)
The underlying problem is more likely at the ESQL/C level than anything to do with other Perl modules. That is, if you compiled and executed this ESQL/C program, it would fail on cms and work on cms#cms_ol:
int main(int argc, char **argv)
{
$ char *dbs = "cms";
if (argc > 1)
dbs = argv[1];
$ whenever error stop;
$ connect to :dbs;
return 0;
}
You could run it without an explicit database name (or with an explicit 'cms'), and I would expect it to fail. You could run it with 'cms#cms_ol' and I would expect it to pass. The program will say nothing if it passes; it will be obvious when it fails (though the messages will not be beautiful).
There is an outside chance it is something to do with connect_cached; that is a service provided by the DBI module and not by the DBD::Informix module. On the whole though, it is more likely something happening at the ESQL/C level.

What is the canonical way to make autoconf link in Solaris network libraries?

On Solaris, when you compile a program that uses sockets, you need to link it with -lnsl -lsocket. Many such programs were originally written for Linux (where no extra libraries are needed), and therefore do not check for these libraries in their configure scripts, even though that is a rather simple addition. Something like this (untested):
AC_SEARCH_LIBS(gethostbyname, nsl, , AC_MSG_ERROR([gethostbyname not found]))
AC_SEARCH_LIBS(connect, socket, , AC_MSG_ERROR([connect not found]))
Is there a canonical way to do this check? Maybe even included in the autoconf distribution? You would imagine that there is a rather widespread need for that, but Google wouldn't tell me.
i think the closest to a canonical way to check this is the AX_LIB_SOCKET_NSL macro from the Autoconf Archive:
# ===========================================================================
# http://www.nongnu.org/autoconf-archive/ax_lib_socket_nsl.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_LIB_SOCKET_NSL
#
# DESCRIPTION
#
# This macro figures out what libraries are required on this platform to
# link sockets programs.
#
# The common cases are not to need any extra libraries, or to need
# -lsocket and -lnsl. We need to avoid linking with libnsl unless we need
# it, though, since on some OSes where it isn't necessary it will totally
# break networking. Unisys also includes gethostbyname() in libsocket but
# needs libnsl for socket().
#
# LICENSE
#
# Copyright (c) 2008 Russ Allbery <rra#stanford.edu>
# Copyright (c) 2008 Stepan Kasal <kasal#ucw.cz>
# Copyright (c) 2008 Warren Young <warren#etr-usa.com>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved.
AU_ALIAS([LIB_SOCKET_NSL], [AX_LIB_SOCKET_NSL])
AC_DEFUN([AX_LIB_SOCKET_NSL],
[
AC_SEARCH_LIBS([gethostbyname], [nsl])
AC_SEARCH_LIBS([socket], [socket], [], [
AC_CHECK_LIB([socket], [socket], [LIBS="-lsocket -lnsl $LIBS"],
[], [-lnsl])])
])
I can't remember any finished code off the top of my head, but you usually want to check whether you can link a program calling the gethostbyname() function without any extra libs first. Only if that fails, you want to try the nsl library.
Similar things apply e.g. for the m library.