Section 4.2. General Differences


4.2. General Differences

With major operating systems such as HP-UX, Solaris, AIX, and Linux embracing standards set forth by standards bodies such as ISO and POSIX, it seems that porting between platforms should be simple. Indeed, when it comes to application programming interfaces (APIs), these operating systems have a lot in common. If only applications were written strictly to these standards, porting them between platforms would be an easy task. Unfortunately, applications that need to be ported from one platform to another usually do not fit the ideal profileone that is completely portable. The nonportable nature of applications stems not only from using nonstandard APIs but also from using new and optional standards available on the source platform that the target platform may have yet to implement. Sometimes, interpretations of standards may vary because some standards leave some points open for interpretation, resulting in different implementations on different platforms. This happens a lot when vendors implement standards on their platforms when they are still in the draft stages. This results in applications written or compiled to draft standards. It appears harmless because the application compiles and runs well on the source platform it was written and built on, but the resulting application is not portable.

In this section, we discuss differences and similarities between Solaris and Linux.

4.2.1. C Language

Sun's C compiler supports most of the language features specified in ISO/IEC 9899:1999 (C99) on operating systems earlier than Solaris 10. However, in Solaris 10, the compiler is in full compliance with the C99 standard.

GCC fully supports two versions of the C standard: C90 and the amendment to the 1990 standard published in 1995 (referred to as C95). Support for the C99 is not yet complete. For more details, visit http://gcc.gnu.org/c99status.html. By default, GCC complies with the C90 standard plus GNU extensions (including some C99 features). To select C90 in GCC, use one of the options -ansi, -std=c89, or -std=iso9899:1990. To select C95 in GCC, use the option -std=iso9899:199409. To select C99, use the option -std=c99 or -std=iso9899:1999.

4.2.2. C++ Language

Sun's latest C++ compiler supports the 1998 ISO International Standard for C++, ISO IS14882:1998. For Linux, g++ is a program that calls GCC with the default language set to C++, and automatically specifies linking against the C++ library. GNU g++ closely conforms to the 1998 ISO/ANSI C++ standard.

Sun's C++ compiler is distributed with a C++ standard library based on the RogueWave Standard C++ Library, version 2, and Tools.h++, version 7.0. On the other hand, GNU g++ ships with the runtime library libstdc++.

4.2.3. GNU C/C++ Language

At the time of this writing, GCC version 3.4.2 is currently available for Solaris 10 (www.sun.com/software/solaris/freeware). If your application can be built successfully using GCC on Solaris, it is most likely that it will be so on Linux. Note that different versions of GCC sometimes conform to different language specifications, especially the C++ standard. Therefore, a recompile with a different version of GCC may not be successful.

4.2.4. Java Language

A Java environment for Linux is available from 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 implementations of the Linux Java SDK are available for download from the Sun and IBM Web sites. Refer to Chapter 2, "Scoping," for more information about the Java environment in Linux.

4.2.5. Threads

Two thread interfaces are supported on Solaris: POSIX threads (commonly known as pthreads) and Solaris threads. Modern Linux distributions support the POSIX thread API standard. If you use Solaris threads, you must change your application when you port it to Linux. Alternatively, you can use the Solaris Compatibility Thread Library (STL) to migrate from the Solaris threads API to the POSIX threads library. For more information on STL, visit http://sourceforge.net/projects/sctl/.

4.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 it also documents those places where Linux is not UNIX- or POSIX-compatible. Most of 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 to the API. 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.[3] This means applications that may be totally portable under these common commercial UNIX standards may still need some work to move successfully to Linux. However, this work will be much less than for an application that meets no standards at all, or uses Solaris-specific UNIX extensions.

[3] Conflicts between ISO/IEC 9945 (POSIX) and the LSB (www.opengroup.org/personal/ajosey/tr01-04-2005.txt)

Table 4-1 provides a comparison of standards conformance between Solaris 10 and Linux supported standards based on the LSB specification version 2.0.1.

Table 4-1. Solaris and Linux Standards

Standard

Solaris 10[4]

Linux 2.6 (GNU libc)[5]

ISO/IEC 9945-1:2001, the POSIX System API (POSIX.1)

Yes (including many of the real-time extension options)

Partial (minor differences in some APIs and a few of the real-time extensions)

ISO/IEC 9945-2:2001, the POSIX Shell and Utilities standard (POSIX.2)

Yes

Partial (regular expressions and pattern-matching facilities)

X/Open Portability Guide Issue 3 (XPG3) (superset of POSIX.1 containing utilities from SVID)

Yes

No (GNU libc defines most of the facilities required by SVID that are not also required by the ISO C or POSIX standards)

X/Open Portability Guide Issue 4 (XPG4)

Yes

Yes

X/Open Portability Guide Issue 4 version 2 (XPG4v2)

Yes

Yes

System V Interface Definition (SVID3)

Yes

Partial

X11 Window System, Font Server, and Clients

Yes

Yes

LP64, 64-bit data model

Yes

Yes


[4] http://docs.sun.com/app/docs/doc/816-5175/6mbba7f3u?a=view

[5] www.gnu.org/software/libc/manual/html_mono/ISO%20C




UNIX to Linux Porting. A Comprehensive Reference
UNIX to Linux Porting: A Comprehensive Reference
ISBN: 0131871099
EAN: 2147483647
Year: 2004
Pages: 175

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net