UltraLite User's Guide
Developing Applications for the Palm Computing Platform
Building multi-segment applications
This section describes how to instruct the UltraLite Analyzer to generate multi-segment code using its default scheme. If you wish to customize the assignment of code to segments by explicitly assigning functions to segments, you can do so. For more information, see Explicitly assigning segments.
You enable generated code segments by defining macros. Macro definition is different for the CodeWarrior and PRC Tools development tools, so the procedure for enabling multi-segment code generation also differs.
To enable multi-segment code generation (CodeWarrior)
Define a prefix file for your CodeWarrior project with the following contents:
#define UL_ENABLE_SEGMENTS #include "ulpalmXX.h"
where XX=30, 31, 35, or 40.
For more information, see UL_ENABLE_SEGMENTS macro.
To enable multi-segment code generation (PRC Tools)
Instruct the gnu compiler to compile segmented code.
Define the following two macros on the compiler command line:
UL_ENABLE_SEGMENTS
UL_ENABLE_GNU_SEGMENTS
For an example, see the file Samples\UltraLite\CustDB\PRCTools20\ build.bat relative to your SQL Anywhere directory.
For more information, see UL_ENABLE_SEGMENTS macro, and .UL_ENABLE_GNU_SEGMENTS macro.
Construct a segment definition file for the GNU link tools multilink and build-prc.
Run the dbulseg command-line utility against each source file, and supply a name for the definition file. For example, the following command line:
dbulseg gensource.c project.def AppName CreatorID
creates a project.def definition file with the following content:
application{ "AppName" CreatorID } multiple code{ ULRT1 ... ULRT17 ULG512 ULG513 ... }
where the ULG segment names are obtained from the generated source file gensource.c.
For more information on the UltraLite segment utility, see The UltraLite segment utility.
When multi-segment code generation is enabled, the default behavior of the UltraLite Analyzer is as follows:
The generated schema code fits into a single segment and is assigned to a segment named ULSEGDB.
For the C++ API, the generated statement code is assigned to a segment named ULSEGDEF.
For embedded SQL, the generated statement code is assigned to a segment with a generated name based on the .sqc file. All the code for a single .sqc file goes into a single segment.
When a function defined at the bottom of a source file makes an inter-segment call to a function defined at the top of the same source file, and there is more than 32 kb of code in between, the PRC Tools compiler may generate jsr instructions unacceptable to the assembler. Normally, the offset of the jsr instruction is replaced during the relocation stage of the linker, but in this case, the error prevents the compilation from going any further. To avoid this issue, instruct the assembler to ignore any signed overflow errors by using the -Wa,-J
compiler switches.