Home > Articles > Operating Systems, Server > Linux/UNIX/Open Source

GNU or Linux?

  • Print
  • + Share This
From the author of

What Does a Developer See?

The important standard when programming for or using *NIX is the Single UNIX Specification (SUS), a superset of POSIX that includes everything that should exist for a system to call itself UNIX. Code written to this standard is portable across a range of UNIX-like systems.

This standard doesn't specify any system calls. Instead, it specifies C functions that wrap the system calls. When a programmer wants to call an open() function, he doesn't need to know that it will store a pointer to a filename in EBX and the value 2 in EAX, and then issue interrupt 80h; the C standard library implements all of these functions. Any nontrivial program running on Linux will link against a C library (libc for short). There are a number of implementations of the C standard library. Each member of the BSD family has one, as do all of the commercial UNIX variants. The most common C standard library on Linux depends on the use; there are several versions for embedded systems, but almost all desktop Linux distributions use GNU libc.

In terms of quantity of code, the kernel and libc are similar. Between the two, they provide the developer's interface to the system. Since the standard defines only the C interfaces, rather than the system calls, most code is written against the C standard library. This rule includes other languages; if you run some Java or Python code, for example, it will access the kernel via the C library. For some languages, the standard library is also provided by the GNU Project. Any C++ code, for example, will use GNU libstdc++ on GNU/Linux platforms. Some distributions also include the GNU implementations of the Java libraries, although this practice is becoming less common now that the Sun versions are open source. Even if you use the Sun Java libraries, however, you're still using GNU libc on these platforms for every Java application you run.

C++ causes even more issues than most other languages. When you link two modules together (for example, an executable and a library), a set of standards defines how those two modules should communicate. When you call a function from another module, the order of the arguments on the stack and in registers, who is responsible for cleaning them up afterwards, and so on must be defined. For C++, other things must be well defined for classes in different modules to be usable. This set of standards is called an application binary interface (ABI). Under Linux, the C++ ABI is defined by GCC, a GNU package. The layout of compiled C++ code, irrespective of which compiler you use, must conform to the GNU definitions, or it will not be usable by other C++ code.

  • + Share This
  • 🔖 Save To Your Account