5.2. General Differences
A common misconception is that the more familiar you are with the code you are porting, the more successful the port will be. In fact, first and foremost, your biggest advantage is how familiar you are with the source build environment. Familiarity with the code is second, although not required. On the other hand, not being familiar with the ported code will not hinder the porting effort. Instead, having a good knowledge of ANSI C/C++, ISO, and POSIX standards will give you a greater advantage than knowing the code. These skills are needed to help you assess and troubleshoot the code when you have to make surgical and strategic changes in the existing code. This section will help you build on those analytical skills so that you make the correct changes when necessary.
Although both AIX and GNU claim to adhere to ANSI, ISO, and POSIX standards, there are some differences. This section covers those differences between the two platforms and their development environments. Although some example codes are used to clarify points, most of the material covered in this section relates to differences in system calls, compiler and linker invocation, and library creation.
5.2.1. C Language
Both the AIX C compiler and GCC support the ANSI C (ANSI/ISO 9899-1990) standard, but syntax and semantics differences may still prevent an error-free compilation in Linux. Within GCC other standards can be selected by using the -ansi, -std=89, or -std=iso9899:1990 options.
5.2.2. C++ Language
Starting with GNU g++ version 3.4.0, GNU g++ claims to be much closer to the ISO/ANSI C++ standards. This means, among other things, that a lot of invalid constructs that used to be accepted in previous versions will now be rejected. The AIX xlC (C++) compiler implements the latest ANSI C++ standards (including the Standard Template Library, STL) in libC. A GNU g++ compilers implements the latest ANSI C++ standards and STL in the libstdc++ library. For both AIX and GNU, to use the STL you just include the appropriate template library. Overall, this means that although some differences do exist between AIX and GNU, there are minimal differences in standards compliance when migrating from the latest version of AIX C++ to GNU g++. In short, applications written with standards in mind are easier to migrate than those that are not.
5.2.3. GNU C/C++ Language
The GNU Compiler Collection (gcc) is available for AIX. Applications compiled with gcc on AIX make porting and migration easier on Linux. You should be careful when using different versions of the GCC compiler when migrating from AIX to Linux. Applications that compile cleanly on older versions of GCC might not compile as well on new versions because of changes in programming standards, specifically in the C++ language.
5.2.4. Java Language
The AIX SDK for the Java platform provides the Java 2 (version 1.4) programming tools and runtime environment. The Java environment is available for Linux through the Blackdown Java SDK (www.blackdown.org). As of this writing, Blackdown has released Java version 1.4.2 and is working on release version 1.5. Other Linux Java SDKs are available for download from Sun and IBM Web sites.
AIX 5L supports the POSIX threads implementation. Previous versions of AIX prior to release 5L supported DCE pthreads. Applications using DCE threads will need some major changes to use POSIX threads on Linux. Refer to Section 5.16, Posix Threads, for more information on differences between AIX and Linux.
5.2.6. Standards Comparison
Almost all Linux distributors acknowledge the values that standardization and portability provide, and work with the various Linux implementers/maintainers to meet those standards. The primary Linux industry standard is the Linux Standard Base (LSB), which is a project overseen by the Free Standards Group (FSG). The LSB (whose most recent version at this time is LSB 3.0) is based heavily on the IEEE POSIX and Open Group Single UNIX Specification standards, but also documents those places where Linux is not UNIX- or POSIX-compatible. Most (and all the major) Linux distributors have certified to the LSB.
The LSB, in addition to providing a source code API specification, also provides a binary interface (ABI) specification for each of several common Linux hardware platforms. The goal of the ABI is to ensure binary portability (for LSB-portable applications) between Linux distributions on that hardware platform. Distributors must certify to the ABI as well as the API. Independent Service Vendors (ISVs) can also certify their applications as "LSB portable" using tools provided by the FSG.
Although there is standardization within Linux, Linux itself is not totally compliant with either the IEEE POSIX or Open Group SUS specifications. This means that applications that may be totally portable under these common commercial UNIX standards may still need some work to move successfully to Linux. Still, considerably less work would be required than for an application that meets no standards at all or that uses AIX-specific UNIX extensions.
Table 5-1 compares AIX supported standards to the Linux supported standards based on the LSB specification version 2.0.1.
With the exception of IEEE POSIX 1003.4a Draft 4 user threads, both AIX and Linux fully support standards. Draft 4 user threads are DCE threads, which are an earlier version of POSIX threads. Because over the years AIX has been available longer than Linux, some earlier versions of AIX support DCE threads, whereas Linux support of threads starts with Native POSIX Threads Library (NPTL), which claims to be more compliant with regular POSIX threads. NPTL is discussed in detail in Chapter 3, "Analysis."