Package trivial-features

trivial-features ensures consistent *features* across multiple Common Lisp implementations.

About This Package

Overview
Specification
Note
References

Overview

For example, on MacOS X platforms, while most Lisps push :DARWIN to *features*, CLISP and Allegro push :MACOS and :MACOSX instead, respectively. Some Lisps might not push any feature suggesting MacOS X at all. trivial-features will make sure all Lisps will have :DARWIN in the *features* list when running on MacOS X. This way, you can write
  #+darwin foo #-darwin bar     
instead of
  #+(or darwin macos macosx) foo
  #-(or darwin macos macosx) bar     
The section Specification describes the set of symbols that should or should not be present in cl:*features* on certain circumstances. This specification is implemented by the trivial-features system which supports a handful of Lisps.

The test suite is, in effect, an implementation using CFFI that is checked against the various implementations in src/tf-*.lisp.

trivial-features is MIT-licenced.

Specification

Introduction

This is a first draft of a description of what symbols should be present in cl:*features* for various platforms. A possible future direction of this documentation might be a CDR - Common Lisp Document Repository document, if it turns out to be a good idea. (Making the language of this document much more precise will be necessary then.)

We will start by limiting ourselves to OS, CPU and endianness features on Windows and POSIX platforms.

There are various possible implementation strategies ranging from null implementations (when the host Lisp already pushes the wanted feature) to using FFI (e. g. calling uname() to grab system information.

Specification
ENDIANNESS
Either :LITTLE-ENDIAN or :BIG-ENDIAN should present in *FEATURES*. For the time being, we will not concern ourselves with other orderings, switchable endianness, etc.
OPERATING SYSTEM
On Windows, :WINDOWS should be present in *features*.

On POSIX systems, the "sysname" information from uname(3) should be used to push the appropriate symbol to *features* by upcasing that string (or downcasing for the "modern" lisps) and interning it in the keyword package.

Examples

:DARWIN :LINUX :NETBSD :OPENBSD :FREEBSD

For convenience, :UNIX should be pushed when running on POSIX/UNIX-like operating system (that doesn't include Windows) and :BSD should be present when running on BSD-based systems (that includes Darwin)
CPU
These features should be mutually exclusive:

:X86 :X86-64 :PPC :PPC64 :MIPS :ALPHA :SPARC :SPARC64 :HPPA :HPPA64

Note

It is debatable whether :X86 shouldn't also be exported on x86-64, and :PPC on ppc64. SBCL doesn't. Other ways to handle, for example, the x86/x86-64 case would be to export something like :PC386 in both cases or have an additional :X86-32. Or finally, have just :X86, :PPC, etc, and add :32-BIT-CPU and :64-BIT-CPU features.

References

Common Lisp Hyperspec (TM): Variable *FEATURES*
Maintaining Portable Lisp Programs, by Christophe Rhodes, February 5, 2004

Exported Symbol Index