- Github com cyanogenmod android git
- Github com cyanogenmod android git
- User-Configurable Settings
- How To Build And Install On Windows
- Running the Tests from the Windows Command Line (cmd)
- Running the Tests from within Visual Studio
- How To Build And Install On Windows with Cygwin
- How To Build And Install On UNIX
- z/OS (Batch/PDS) support outside the UNIX system services environment
- How To Build And Install On The IBM i Family (IBM i, i5/OS OS/400)
- How To Cross Compile ICU
- How To Package ICU
- Important Notes About Using ICU
- Using ICU in a Multithreaded Environment
- ICU 3.4 and later
- ICU 2.6..3.2
- ICU 2.4 and earlier
- Using ICU in a Multithreaded Environment on HP-UX
- Using ICU in a Multithreaded Environment on Solaris
- Windows Platform
- DLL directories and the PATH setting
- Changing your PATH
- UNIX Type Platform
- Platform Dependencies
- Porting To A New Platform
- Data For a New Platform
- Adapting Makefiles For a New Platform
- Platform Dependent Implementations
Github com cyanogenmod android git
llvm-rs-cc: Compiler for Renderscript language
llvm-rs-cc compiles a program in the Renderscript language to generate the following files:
- Bitcode file. Note that the bitcode here denotes the LLVM (Low-Level Virtual Machine) bitcode representation, which will be consumed on an Android device by libbcc (in platform/frameworks/compile/libbcc.git) to generate device-specific executables.
- Reflected APIs for Java. As a result, Android’s Java developers can invoke those APIs from their code.
Note that although Renderscript is C99-like, we enhance it with several distinct, effective features for Android programming. We will use some examples to illustrate these features.
llvm-rs-cc is run on the host and performs many aggressive optimizations. As a result, libbcc on the device can be lightweight and focus on machine-dependent code generation for some input bitcode.
llvm-rs-cc is a driver on top of libslang. The architecture of libslang and libbcc is depicted in the following figure:
This option specifies the directory for outputting a .bc file.
The option -p denotes the directory for outputting the reflected Java files.
This option -d sets the directory for writing dependence information.
Note that -MD will tell llvm-rs-cc to output dependence information.
Specifies additional target dependencies.
Using frameworks/base/tests/RenderScriptTests/Fountain as a simple app in both Java and Renderscript, we can find the following command line in the build log:
This command will generate:
- fountain.bc
- ScriptC_fountain.java
- ScriptField_Point.java
The Script*.java files above will be documented below.
Example Program: fountain.rs
fountain.rs is in the Renderscript language, which is based on the standard C99. However, llvm-rs-cc goes beyond «clang -std=c99» and provides the following important features:
#pragma rs java_package_name([PACKAGE_NAME])
The ScriptC_[SCRIPT_NAME].java has to be packaged so that Java developers can invoke those APIs.
To do that, a Renderscript programmer should specify the package name, so that llvm-rs-cc knows the package expression and hence the directory for outputting ScriptC_[SCRIPT_NAME].java.
In fountain.rs, we have:
In ScriptC_fountain.java, we have:
Note that the ScriptC_fountain.java will be generated inside ./com/android/fountain/.
This pragma is for evolving the language. Currently we are at version 1 of the language.
2. Basic Reflection: Export Variables and Functions
llvm-rs-cc automatically exports the «externalizable and defined» functions and variables to Android’s Java side. That is, scripts are accessible from Java.
For instance, for:
In ScriptC_fountain.java, llvm-rs-cc will reflect the following methods:
This access takes the form of generated classes which provide access to the functions and global variables within a script. In summary, global variables and functions within a script that are not declared static will generate get, set, or invoke methods. This provides a way to set the data within a script and call its functions.
Take the addParticles function in fountain.rs as an example:
llvm-rs-cc will genearte ScriptC_fountain.java as follows:
3. Export User-Defined Structs
In fountain.rs, we have:
llvm-rs-cc generates one ScriptField*.java file for each user-defined struct. In this case, llvm-rs-cc will reflect two files, ScriptC_fountain.java and ScriptField_Point.java.
Note that when the type of an exportable variable is a structure, Renderscript developers should avoid using anonymous structs. This is because llvm-rs-cc uses the struct name to identify the file, instead of the typedef name.
For the generated Java files, using ScriptC_fountain.java as an example we also have:
This binds your object with the allocated memory.
You can bind the struct(e.g., Point), using the setter and getter methods in ScriptField_Point.java.
After binding, you can access the object with this method:
4. Summary of the Java Reflection above
This section summarizes the high-level design of Renderscript’s reflection.
In terms of a script’s global functions, they can be called from Java. These calls operate asynchronously and no assumptions should be made on whether a function called will have actually completed operation. If it is necessary to wait for a function to complete, the Java application may call the runtime finish() method, which will wait for all the script threads to complete pending operations. A few special functions can also exist:
The function init (if present) will be called once after the script is loaded. This is useful to initialize data or anything else the script may need before it can be used. The init function may not depend on globals initialized from Java as it will be called before these can be initialized. The function signature for init must be:
The function root is a special function for graphics. This function will be called when a script must redraw its contents. No assumptions should be made as to when this function will be called. It will only be called if the script is bound as a graphics root. Calls to this function will be synchronized with data updates and other invocations from Java. Thus the script will not change due to external influence in the middle of running root. The return value indicates to the runtime when the function should be called again to redraw in the future. A return value of 0 indicates that no redraw is necessary until something changes on the Java side. Any positive integer indicates a time in milliseconds that the runtime should wait before calling root again to render another frame. The function signature for a graphics root functions is as follows:
It is also possible to create a purely compute-based root function. Such a function has the following signature:
T1, T2, and T3 represent any supported Renderscript type. Any parameters above can be omitted, although at least one of in/out must be present. If both in and out are present, root must only be invoked with types of the same exact dimensionality (i.e. matching X and Y values for dimension). This root function is accessible through the Renderscript language construct forEach. We also reflect a Java version to access this function as forEach_root (for API levels of 14+). An example of this can be seen in the Android SDK sample for HelloCompute.
The function .rs.dtor is a function that is sometimes generated by llvm-rs-cc. This function cleans up any global variable that contains (or is) a reference counted Renderscript object type (such as an rs_allocation, rs_font, or rs_script). This function will be invoked implicitly by the Renderscript runtime during script teardown.
In terms of a script’s global data, global variables can be written from Java. The Java instance will cache the value or object set and provide return methods to retrieve this value. If a script updates the value, this update will not propagate back to the Java class. Initializers, if present, will also initialize the cached Java value. This provides a convenient way to declare constants within a script and make them accessible to the Java runtime. If the script declares a variable const, only the get methods will be generated.
Globals within a script are considered local to the script. They cannot be accessed by other scripts and are in effect always ‘static’ in the traditional C sense. Static here is used to control if accessors are generated. Static continues to mean not externally visible and thus prevents the generation of accessors. Globals are persistent across invocations of a script and thus may be used to hold data from run to run.
Globals of two types may be reflected into the Java class. The first type is basic non-pointer types. Types defined in rs_types.rsh may also be used. For the non-pointer class, get and set methods are generated for Java. Globals of single pointer types behave differently. These may use more complex types. Simple structures composed of the types in rs_types.rsh may also be used. These globals generate bind points in Java. If the type is a structure they also generate an appropriate Field class that is used to pack and unpack the contents of the structure. Binding an allocation in Java effectively sets the pointer in the script. Bind points marked const indicate to the runtime that the script will not modify the contents of an allocation. This may allow the runtime to make more effective use of threads.
Vector types such as float2, float4, and uint4 are included to support vector processing in environments where the processors provide vector instructions.
On non-vector systems the same code will continue to run but without the performance advantage. Function overloading is also supported. This allows the runtime to support vector version of the basic math routines without the need for special naming. For instance,
Источник
Github com cyanogenmod android git
- Data path: For a system-level library, it is best to load ICU data from the .dat package file because the file system path to the .dat package file can be hardcoded. ICU will automatically set the path to the final install location using U_ICU_DATA_DEFAULT_DIR. Alternatively, you can set -DICU_DATA_DIR=/path/to/icu/data when building the ICU code. (Used by source/common/putil.c.)
Consider also setting -DICU_NO_USER_DATA_OVERRIDE if you do not want the «ICU_DATA» environment variable to be used. (An application can still override the data path via u_setDataDirectory() or udata_setCommonData() . - Hide draft API: API marked with @draft is new and not yet stable. Applications must not rely on unstable APIs from a system-level library. Define U_HIDE_DRAFT_API , U_HIDE_INTERNAL_API and U_HIDE_SYSTEM_API by modifying unicode/utypes.h before installing it.
- Only C APIs: Applications must not rely on C++ APIs from a system-level library because binary C++ compatibility across library and compiler versions is very hard to achieve. Most ICU C++ APIs are in header files that contain a comment with \brief C++ API . Consider not installing these header files.
- Disable renaming: By default, ICU library entry point names have an ICU version suffix. Turn this off for a system-level installation, to enable upgrading ICU without breaking applications. For example:
runConfigureICU Linux —disable-renaming
The public header files from this configuration must be installed for applications to include and get the correct entry point names.
User-Configurable Settings
ICU4C can be customized via a number of user-configurable settings. Many of them are controlled by preprocessor macros which are defined in the source/common/unicode/uconfig.h header file. Some turn off parts of ICU, for example conversion or collation, trading off a smaller library for reduced functionality. Other settings are recommended (see previous section) but their default values are set for better source code compatibility.
In order to change such user-configurable settings, you can either modify the uconfig.h header file by adding a specific #define . for one or more of the macros before they are first tested, or set the compiler’s preprocessor flags ( CPPFLAGS ) to include an equivalent -D macro definition.
How To Build And Install On Windows
Building International Components for Unicode requires:
- Microsoft Windows
- Microsoft Visual C++
- Cygwin is required when other versions of Microsoft Visual C++ and other compilers are used to build ICU.
- Unzip the icu-XXXX.zip file into any convenient location. Using command line zip, type «unzip -a icu-XXXX.zip -d drive:\directory», or just use WinZip.
- Be sure that the ICU binary directory, \bin\, is included in the PATH environment variable. The tests will not work without the location of the ICU DLL files in the path.
- Open the » \source\allinone\allinone.sln» workspace file in Microsoft Visual Studio. (This solution includes all the International Components for Unicode libraries, necessary ICU building tools, and the test suite projects). Please see the command line note below if you want to build from the command line instead.
- Set the active platform to «Win32» or «x64» (See Windows platform note below) and configuration to «Debug» or «Release» (See Windows configuration note below).
- Choose the «Build» menu and select «Rebuild Solution». If you want to build the Debug and Release at the same time, see the batch configuration note below.
- Run the tests. They can be run from the command line or from within Visual Studio.
Running the Tests from the Windows Command Line (cmd)
- For x86 (32 bit) and Debug, use:
\source\allinone\icucheck.bat PlatformConfiguration - So, for example:
\source\allinone\icucheck.bat x86Debug
or
\source\allinone\icucheck.bat x86Release
or
\source\allinone\icucheck.bat x64Release
Running the Tests from within Visual Studio
- Run the C++ test suite, «intltest». To do this: set the active startup project to «intltest», and press Ctrl+F5 to run it. Make sure that it passes without any errors.
- Run the C test suite, «cintltst». To do this: set the active startup project to «cintltst», and press Ctrl+F5 to run it. Make sure that it passes without any errors.
- Run the I/O test suite, «iotest». To do this: set the active startup project to «iotest», and press Ctrl+F5 to run it. Make sure that it passes without any errors.
Using MSDEV At The Command Line Note: You can build ICU from the command line. Assuming that you have properly installed Microsoft Visual C++ to support command line execution, you can run the following command, ‘devenv.com \source\allinone\allinone.sln /build «Win32|Release»‘. You can also use Cygwin with this compiler to build ICU, and you can refer to the How To Build And Install On Windows with Cygwin section for more details.
Setting Active Platform Note: Even though you are able to select «x64» as the active platform, if your operating system is not a 64 bit version of Windows, the build will fail. To set the active platform, two different possibilities are:
- Choose «Build» menu, select «Configuration Manager. «, and select «Win32» or «x64» for the Active Platform Solution.
- Another way is to select the desired build configuration from «Solution Platforms» dropdown menu from the standard toolbar. It will say «Win32» or «x64» in the dropdown list.
Setting Active Configuration Note: To set the active configuration, two different possibilities are:
- Choose «Build» menu, select «Configuration Manager. «, and select «Release» or «Debug» for the Active Configuration Solution.
- Another way is to select the desired build configuration from «Solution Configurations» dropdown menu from the standard toolbar. It will say «Release» or «Debug» in the dropdown list.
Batch Configuration Note: If you want to build the Win32 and x64 platforms and Debug and Release configurations at the same time, choose «Build» menu, and select «Batch Build. «. Click the «Select All» button, and then click the «Rebuild» button.
How To Build And Install On Windows with Cygwin
Building International Components for Unicode with this configuration requires:
- Microsoft Windows
- Microsoft Visual C++ (when gcc isn’t used).
- Cygwin with the following installed:
- bash
- GNU make
- ar
- ranlib
- man (if you plan to look at the man pages)
There are two ways you can build ICU with Cygwin. You can build with gcc or Microsoft Visual C++. If you use gcc, the resulting libraries and tools will depend on the Cygwin environment. If you use Microsoft Visual C++, the resulting libraries and tools do not depend on Cygwin and can be more easily distributed to other Windows computers (the generated man pages and shell scripts still need Cygwin). To build with gcc, please follow the «How To Build And Install On UNIX» instructions, while you are inside a Cygwin bash shell. To build with Microsoft Visual C++, please use the following instructions:
- Start the Windows «Command Prompt» window. This is different from the gcc build, which requires the Cygwin Bash command prompt. The Microsoft Visual C++ compiler will not work with a bash command prompt.
- If the computer isn’t set up to use Visual C++ from the command line, you need to run vcvars32.bat.
For example:
«C:\Program Files\Microsoft Visual Studio 8\VC\bin\vcvars32.bat» can be used for 32-bit builds or
«C:\Program Files (x86)\Microsoft Visual Studio 8\VC\bin\amd64\vcvarsamd64.bat» can be used for 64-bit builds on Windows x64. - Unzip the icu-XXXX.zip file into any convenient location. Using command line zip, type «unzip -a icu-XXXX.zip -d drive:\directory», or just use WinZip.
- Change directory to «icu/source», which is where you unzipped ICU.
- Run «bash ./runConfigureICU Cygwin/MSVC» (See Windows configuration note and non-functional configure options below).
- Type "make" to compile the libraries and all the data files. This make command should be GNU make.
- Optionally, type "make check" to run the test suite, which checks for ICU’s functionality integrity (See testing note below).
- Type "make install" to install ICU. If you used the —prefix= option on configure or runConfigureICU, ICU will be installed to the directory you specified. (See installation note below).
Ensure that the order of the PATH is MSVC, Cygwin, and then other PATHs. The configure script needs certain tools in Cygwin (e.g. grep).
Also, you may need to run "dos2unix.exe" on all of the scripts (e.g. configure) in the top source directory of ICU. To avoid this issue, you can download the ICU source for Unix platforms (icu-xxx.tgz).
In addition to the Unix configuration note the following configure options currently do not work on Windows with Microsoft’s compiler. Some options can work by manually editing icu/source/common/unicode/pwin32.h, but manually editing the files is not recommended.
- --disable-renaming
- --disable-threading (This flag does disable threading in ICU, but the resulting ICU library will still be linked with MSVC’s multithread DLL)
- --enable-tracing
- --enable-rpath
- --with-iostream
- --enable-static (Requires that U_STATIC_IMPLEMENTATION be defined in user code that links against ICU’s static libraries.)
- --with-data-packaging=files (The pkgdata tool currently does not work in this mode. Manual packaging is required to use this mode.)
How To Build And Install On UNIX
Building International Components for Unicode on UNIX requires:
- A C++ compiler installed on the target machine (for example: gcc, CC, xlC_r, aCC, cxx, etc. ).
- An ANSI C compiler installed on the target machine (for example: cc).
- A recent version of GNU make (3.80+).
- For a list of z/OS tools please view the z/OS build section of this document for further details.
Here are the steps to build ICU:
- Decompress the icu-X.Y.tgz (or icu-X.Y.tar.gz) file. For example, "gunzip -d http://www-03.ibm.com/servers/eserver/zseries/zos/unix/bpxa1toy.html">z/OS UNIX - Tools and Toys site. The PATH environment variable should be updated to contain the location of this executable prior to build. Failure to add these tools to your PATH will cause ICU build failures or cause pkgdata to fail to run.
- Since USS does not support using the mmap() function over NFS, it is recommended that you build ICU on a local filesystem. Once ICU has been built, you should not have this problem while using ICU when the data library has been built as a shared library, which is this is the default setting.
- Encoding considerations: The source code assumes that it is compiled with codepage ibm-1047 (to be exact, the UNIX System Services variant of it). The pax command converts all of the source code files from ASCII to codepage ibm-1047 (USS) EBCDIC. However, some files are binary files and must not be converted, or must be converted back to their original state. You can use the unpax-icu.sh script to do this for you automatically. It will unpackage the tar file and convert all the necessary files for you automatically.
- z/OS supports both native S/390 hexadecimal floating point and (with OS/390 2.6 and later) IEEE 754 binary floating point. This is a compile time option. Applications built with IEEE should use ICU DLLs that are built with IEEE (and vice versa). The environment variable IEEE390=0 will cause the z/OS version of ICU to be built without IEEE floating point support and use the native hexadecimal floating point. By default ICU is built with IEEE 754 support. Native floating point support is sufficient for codepage conversion, resource bundle and UnicodeString operations, but the Format APIs require IEEE binary floating point.
- z/OS introduced the concept of Extra Performance Linkage (XPLINK) to bring performance improvement opportunities to call-intensive C and C++ applications such as ICU. XPLINK is enabled on a DLL-by-DLL basis, so if you are considering using XPLINK in your application that uses ICU, you should consider building the XPLINK-enabled version of ICU. You need to set ICU's environment variable OS390_XPLINK=1 prior to invoking the make process to produce binaries that are enabled for XPLINK. The XPLINK option, which is available for z/OS 1.2 and later, requires the PTF PQ69418 to build XPLINK enabled binaries.
- Currently in ICU 3.0, there is an issue with building on z/OS without XPLINK and with the C++ iostream. By default, the iostream library on z/OS is XPLINK enabled. If you are not building an XPLINK enabled version of ICU, you should use the --with-iostream=old configure option when using runConfigureICU. This will prevent applications that use the icuio library from crashing.
- Also note that on current versions of z/OS, the XPLINK" rel="nofollow">http://www-01.ibm.com/support/docview.wss?uid=swg21202407&wv=1'>XPLINK version (C128) of the C++ standard library is standard. Therefore you may see an error when running with XPLINK disabled. To avoid this error, set the following environment variable or similar:
- The rest of the instructions for building and testing ICU on z/OS with UNIX System Services are the same as the How To Build And Install On UNIX section.
z/OS (Batch/PDS) support outside the UNIX system services environment
By default, ICU builds its libraries into the UNIX file system (HFS). In addition, there is a z/OS specific environment variable (OS390BATCH) to build some libraries into the z/OS native file system. This is useful, for example, when your application is externalized via Job Control Language (JCL).
The OS390BATCH environment variable enables non-UNIX support including the batch environment. When OS390BATCH is set, the libicui18nXX.dll, libicuucXX.dll, and libicudtXXe.dll binaries are built into data sets (the native file system). Turning on OS390BATCH does not turn off the normal z/OS UNIX build. This means that the z/OS UNIX (HFS) DLLs will always be created.
Two additional environment variables indicate the names of the z/OS data sets to use. The LOADMOD environment variable identifies the name of the data set that contains the dynamic link libraries (DLLs) and the LOADEXP environment variable identifies the name of the data set that contains the side decks, which are normally the files with the .x suffix in the UNIX file system.
A data set is roughly equivalent to a UNIX or Windows file. For most kinds of data sets the operating system maintains record boundaries. UNIX and Windows files are byte streams. Two kinds of data sets are PDS and PDSE. Each data set of these two types contains a directory. It is like a UNIX directory. Each "file" is called a "member". Each member name is limited to eight bytes, normally EBCDIC.
Here is an example of some environment variables that you can set prior to building ICU:
The PDS member names for the DLL file names are as follows:
You should point the LOADMOD environment variable at a partitioned data set extended (PDSE) and point the LOADEXP environment variable at a partitioned data set (PDS). The PDSE can be allocated with the following attributes:
The PDS can be allocated with the following attributes:
How To Build And Install On The IBM i Family (IBM i, i5/OS OS/400)
Before you start building ICU, ICU requires the following:
- QSHELL interpreter installed (install base option 30, operating system) QShell Utilities, PRPQ 5799-XEH (not required for V4R5)
- ILE C/C++ Compiler installed on the system
- The latest IBM tools for Developers for IBM i — http://www.ibm.com/servers/enable/site/porting/tools/ http://www.ibm.com/servers/enable/site/porting/tools/'>http://www.ibm.com/servers/enable/site/porting/tools/
The following describes how to setup and build ICU. For background information, you should look at the UNIX build instructions.
How To Cross Compile ICU
This section will explain how to build ICU on one platform, but to produce binaries intended to run on another. This is commonly known as a cross compile.
Normally, in the course of a build, ICU needs to run the tools that it builds in order to generate and package data and test-data.In a cross compilation setting, ICU is built on a different system from that which it eventually runs on. An example might be, if you are building for a small/headless system (such as an embedded device), or a system where you can't easily run the ICU command line tools (any non-UNIX-like system).
To reduce confusion, we will here refer to the "A" and the "B" system.System "A" is the actual system we will be running on- the only requirements on it is are it is able to build ICU from the command line targetting itself (with configure or runConfigureICU), and secondly, that it also contain the correct toolchain for compiling and linking for the resultant platform, referred to as the "B" system.
Three initially-empty directories will be used in this example:
/icu | a copy of the ICU source |
---|---|
/buildA | an empty directory, it will contain ICU built for A (MacOSX in this case) |
/buildB | an empty directory, it will contain ICU built for B (HaikuOS in this case) |
- Check out or unpack the ICU source code into the /icu directory.You will have the directories /icu/source, etc.
- Build ICU in /buildA normally (using runConfigureICU or configure):
- Set PATH or other variables as needed, such as CPPFLAGS.
- Build ICU in /buildB
How To Package ICU
There are many ways that a person can package ICU with their software products. Usually only the libraries need to be considered for packaging.
On UNIX, you should use "gmake install" to make it easier to develop and package ICU. The bin, lib and include directories are needed to develop applications that use ICU. These directories will be created relative to the "--prefix=dir" configure option (See the UNIX build instructions). When ICU is built on Windows, a similar directory structure is built.
When changes have been made to the standard ICU distribution, it is recommended that at least one of the following guidelines be followed for special packaging.
- Add a suffix name to the library names. This can be done with the --with-library-suffix configure option.
- The installation script should install the ICU libraries into the application's directory.
Library Name | Windows Filename | Linux Filename | Comment |
---|---|---|---|
Data Library | icudtXYl.dll | libicudata.so.XY.Z | Data required by the Common and I18n libraries. There are many ways to package and customize" rel="nofollow">http://userguide.icu-project.org/icudata">customize this data, but by default this is all you need. |
Common Library | icuucXY.dll | libicuuc.so.XY.Z | Base library required by all other ICU libraries. |
Internationalization (i18n) Library | icuinXY.dll | libicui18n.so.XY.Z | A library that contains many locale based internationalization (i18n) functions. |
Layout Engine | iculeXY.dll | libicule.so.XY.Z | An optional engine for doing font layout. |
Layout Extensions Engine | iculxXY.dll | libiculx.so.XY.Z | An optional engine for doing font layout that uses parts of ICU. |
ICU I/O (Unicode stdio) Library | icuioXY.dll | libicuio.so.XY.Z | An optional library that provides a stdio like API with Unicode support. |
Tool Utility Library | icutuXY.dll | libicutu.so.XY.Z | An internal library that contains internal APIs that are only used by ICU's tools. If you do not use ICU's tools, you do not need this library. |
Normally only the above ICU libraries need to be considered for packaging. The versionless symbolic links to these libraries are only needed for easier development. The X, Y and Z parts of the name are the version numbers of ICU. For example, ICU 2.0.2 would have the name libicuuc.so.20.2 for the common library. The exact format of the library names can vary between platforms due to how each platform can handles library versioning.
Important Notes About Using ICU
Using ICU in a Multithreaded Environment
Some versions of ICU require calling the u_init() function from uclean.h to ensure that ICU is initialized properly. In those ICU versions, u_init() must be called before ICU is used from multiple threads. There is no harm in calling u_init() in a single-threaded application, on a single-CPU machine, or in other cases where u_init() is not required.
In addition to ensuring thread safety, u_init() also attempts to load at least one ICU data file. Assuming that all data files are packaged together (or are in the same folder in files mode), a failure code from u_init() usually means that the data cannot be found. In this case, the data may not be installed properly, or the application may have failed to call udata_setCommonData() or u_setDataDirectory() which specify to ICU where it can find its data.
Since u_init() will load only one or two data files, it cannot guarantee that all of the data that an application needs is available. It cannot check for all data files because the set of files is customizable, and some ICU services work without loading any data at all. An application should always check for error codes when opening ICU service objects (using ucnv_open() , ucol_open() , C++ constructors, etc.).
ICU 3.4 and later
ICU 3.4 self-initializes properly for multi-threaded use. It achieves this without performance penalty by hardcoding the core Unicode properties data, at the cost of some flexibility. (For details see Jitterbug 4497.)
u_init() can be used to check for data loading. It tries to load the converter alias table ( cnvalias.icu ).
ICU 2.6..3.2
These ICU versions require a call to u_init() before multi-threaded use. The services that are directly affected are those that don't have a service object and need to be fast: normalization and character properties.
u_init() loads and initializes the data files for normalization and character properties ( unorm.icu and uprops.icu ) and can therefore also be used to check for data loading.
ICU 2.4 and earlier
ICU 2.4 and earlier versions were not prepared for multithreaded use on multi-CPU platforms where the CPUs implement weak memory coherency. These CPUs include: Power4, Power5, Alpha, Itanium. u_init() was not defined yet.
Using ICU in a Multithreaded Environment on HP-UX
Using ICU in a Multithreaded Environment on Solaris
Linking on Solaris
In order to avoid synchronization and threading issues, developers are suggested to strictly follow the compiling and linking guidelines for multithreaded applications, specified in the following document from Sun Microsystems. Most notably, pay strict attention to the following statements from Sun:
To use libthread, specify -lthread before -lc on the ld command line, or last on the cc command line.
To use libpthread, specify -lpthread before -lc on the ld command line, or last on the cc command line.
Failure to do this may cause spurious lock conflicts, recursive mutex failure, and deadlock.
Source: "Solaris Multithreaded Programming Guide, Compiling and Debugging", Sun Microsystems, Inc., Apr 2004
http://docs.sun.com/app/docs/doc/816-5137/6mba5vpke?a=view
Windows Platform
If you are building on the Win32 platform, it is important that you understand a few of the following build details.
DLL directories and the PATH setting
As delivered, the International Components for Unicode build as several DLLs, which are placed in the " \bin" directory. You must add this directory to the PATH environment variable in your system, or any executables you build will not be able to access International Components for Unicode libraries. Alternatively, you can copy the DLL files into a directory already in your PATH, but we do not recommend this. You can wind up with multiple copies of the DLL and wind up using the wrong one.
Changing your PATH
Windows 2000/XP: Use the System Icon in the Control Panel. Pick the "Advanced" tab. Select the "Environment Variables. " button. Select the variable PATH in the lower box, and select the lower "Edit. " button. In the "Variable Value" box, append the string "; \bin" to the end of the path string. If there is nothing there, just type in " \bin". Click the Set button, then the OK button.
Note: When packaging a Windows application for distribution and installation on user systems, copies of the ICU DLLs should be included with the application, and installed for exclusive use by the application. This is the only way to insure that your application is running with the same version of ICU, built with exactly the same options, that you developed and tested with. Refer to Microsoft's guidelines on the usage of DLLs, or search for the phrase "DLL hell" on msdn.microsoft.com.
UNIX Type Platform
If you are building on a UNIX platform, and if you are installing ICU in a non-standard location, you may need to add the location of your ICU libraries to your LD_LIBRARY_PATH or LIBPATH environment variable (or the equivalent runtime library path environment variable for your system). The ICU libraries may not link or load properly without doing this.
Note that if you do not want to have to set this variable, you may instead use the --enable-rpath option at configuration time. This option will instruct the linker to always look for the libraries where they are installed. You will need to use the appropriate linker options when linking your own applications and libraries against ICU, too. Please refer to your system's linker manual for information about runtime paths. The use of rpath also means that when building a new version of ICU you should not have an older version installed in the same place as the new version's installation directory, as the older libraries will used during the build, instead of the new ones, likely leading to an incorrectly build ICU. This is the proper behavior of rpath.
Platform Dependencies
Porting To A New Platform
If you are using ICU's Makefiles to build ICU on a new platform, there are a few places where you will need to add or modify some files. If you need more help, you can always ask the icu-support" rel="nofollow">http://site.icu-project.org/contacts">icu-support mailing list. Once you have finished porting ICU to a new platform, it is recommended that you contribute your changes back to ICU via the icu-support mailing list. This will make it easier for everyone to benefit from your work.
Data For a New Platform
For some people, it may not be necessary for completely build ICU. Most of the makefiles and build targets are for tools that are used for building ICU's data, and an application's data (when an application uses ICU resource bundles for its data).
ICU 3.6 removes the requirement that ICU be completely built in the native operating environment. It adds the icupkg tool which can be run on any platform to turn binary ICU data files from any one of the three formats into any one of the other data formats. This allows a application to use ICU data built anywhere to be used for any other target platform.
WARNING! Building ICU without running the tests is not recommended. The tests verify that ICU is safe to use. It is recommended that you try to completely port and test ICU before using the libraries for your own application.
Adapting Makefiles For a New Platform
Try to follow the build steps from the UNIX build instructions. If the configure script fails, then you will need to modify some files. Here are the usual steps for porting to a new platform:
Platform Dependent Implementations
The platform dependencies have been mostly isolated into the following files in the common library. This information can be useful if you are porting ICU to a new platform.
- unicode/platform.h.in (autoconf'ed platforms)
unicode/pXXXX.h (others: pwin32.h, ppalmos.h, ..): Platform-dependent typedefs and defines:
- Generic types like UBool, int8_t, int16_t, int32_t, int64_t, uint64_t etc.
- U_EXPORT and U_IMPORT for specifying dynamic library import and export
- usability
- Thread safety usability
- uprv_isNaN, uprv_isInfinite, uprv_getNaN and uprv_getInfinity for handling special floating point values.
- uprv_tzset, uprv_timezone, uprv_tzname and time for getting platform specific time and time zone information.
- u_getDataDirectory for getting the default data directory.
- uprv_getDefaultLocaleID for getting the default locale setting.
- uprv_getDefaultCodepage for getting the default codepage encoding.
umapfile.h, umapfile.c: functions for mapping or otherwise reading or loading files into memory. All access by ICU to data from files makes use of these functions.
Copyright © 1997-2012 International Business Machines Corporation and others. All Rights Reserved.
IBM Globalization Center of Competency - San José
4400 North First Street
San José, CA 95134
USA
Источник