by Ravi Murty, senior network software engineer, Corporate Technology Group, and Ashok Raj, senior staff software engineer, Intel Corp.
Writing code just got easier
There may be no such thing as completely portable code, but with the release of a new Linux version of a component library to developers, writing portable, adaptable code just got easier. A noncommercial product, the Intel® operating system independent (OSI) library implementation called CompLib has been used by Intel developers to port their applications from one platform to another. Now this rigorously tested and effective tool is available to any software engineer wanting access to a critical resource for creating more flexible, robust applications.
With today's large and complex applications, there are strong incentives to reuse and port code to new platforms. A lack of readily available OSI libraries has hindered efforts to generate applications that can easily port from one system to another. But by using CompLib, a developer can do more than write code that is just adapted to new operating systems.
What is CompLib?
CompLib is an operating system independent (OSI) library of functions that abstracts the OS services and performs some porting tasks for you. It includes abstractions for common OS primitives, such as memory allocation, deallocation, spinlocks, semaphores, timers, events, and so on. In addition, CompLib also abstracts compiler directives to hide differences between different compilers and tools. One example of this is the directive that lets the writer pack a structure.
For example, Figure 1 below shows a segment of code that allocates memory and checks the value of the returned pointer. In Figure 1, the code is implemented using #ifdef’s to make it portable across several different OSes. Figure 2 shows the same code written using CompLib. Notice that cl_malloc() is implemented for each OS. It is evident from looking at the code that the code is not only portable and extendible to a new OS—by implementing a flavor of CompLib for that new OS—but it will also be easy to read and maintain.
Figure 1. Code that tries to allocate a block of memory.
Figure 2. Code written with an OSI library.
With an OSI library such as CompLib, developers can now write most or all of their drivers and applications independent of the operating system. Once they implement CompLib functions in the base code, they can move between platforms fairly quickly.
The Intel OSI reference implementation, CompLib, currently supports four OSes: Windows, Linux, EFI (Extensible Firmware Interface), and VxWorks. The Linux version of CompLib is now available (free) online for developers to use.
Advantages to porting code
Although portable code is not appropriate for all projects, it does have its advantages, including:
![]()
![]() | J2EE performance optimization, part 1: laying the foundation by Kingsum Chow, PhD, senior performance architect with the Managed ... |
![]() | J2EE performance optimization, part 3 - design of experiments for performance tuning by Kingsum Chow, Ph.D., senior performance architect, Managed Runtime ... |
If you're interested in this topic, these articles may be helpful:
![]() | Dalmaker XE source-code generation tool from TLWallace.NET Dalmaker, a source-code generation toolset, will... |
![]() | Source code for 'Network Security with OpenSSL: Cryptography for Secure Communications' by John Viega, Matt Messier, and Pravir Chandra. O'Reilly Media Ve... |
![]() | Maximum FPS: three tips for faster code by Dean Macri, Solutions Enabling Group, Intel Corp. Welcome back t... |
![]() | Web Code Optimization: Google does it. Yahoo! does it. Why don't you do it? by Tad Fleshman. Port80 Software Inc. Google and Yahoo! know that s... |
![]() | Model with the Eclipse Modeling Framework, part 2: generate code with Eclipse's Java Emitter Templates by Adrian Powell, senior software developer, IBM Corp. First published... |
![]()
Related Jobs:

