# SYSTEM system

## What does the SYSTEM system do?

It serves several purposes:

- Sets platform dependant properties like big or little endian and floating-point layout.
- Forces the product to define types required by Opera core.
- Lets the product choose between different implementations of every required function in the c stdlib

### System properties

All system settings have a name on the form SYSTEM_NAME. That define has to be set by the product to be able to compile Opera. Example:

    SYSTEM_BIG_ENDIAN							kilsmo

    	Set this one to YES if you have a processor that has big endian byte order (680x0, PowerPC, etc).
    	Some processors have little endian byte order (x86, etc).

    	Defines  : OPERA_BIG_ENDIAN

On the product side, for big endian systems, you do:

    #define SYSTEM_BIG_ENDIAN YES

and for little endian systems you do:

    #define SYSTEM_BIG_ENDIAN NO

Not setting this will cause a compile error.
The syntax of system.txt is similar to that of `features.txt`. See the FEATURES system for a description of the syntax.

### Types

There are several types which are used by the Opera core code which are not present in the C++ language. For instance UINT32 which describes an unsigned integer of size 32 bits or OpFileLength which is used for describing file length, some systems may be able to set this to a 64 bit integer, or some may set it to 32.
All types must be available, if not, they will cause an immediate compile error.

### Stdlib macros

Inside the Opera core code all C stdlib functions are referred to as `op_strlen()`, `op_sprintf()` etc. See the coding standard. All these functions have an implementation in core (available in modules/stdlib). There are SYSTEM-entries for all these functions where the product can choose between the implementation in core or the one on the platform.
Example:

    SYSTEM_MEMCMP								lth

    	The system has the following function:

    	int memcmp(void char* s1, const void* s2, size_t nbytes);

    	If SYSTEM_MEMCMP==NO then the macro op_memcmp need not be defined.

    	Group    : library
    	Defines  : HAVE_MEMCMP

    macro op_memcmp								markus

    	  Defines a macro which compares the first n bytes of the
    	  memory areas s1 and s2. It returns an integer less than,
    	  equal to, or greater than zero if s1 is found, respectively,
    	  to be less than, to match, or be greater than s2.

    	  int op_memcmp(const void* s1, const void* s2, size_t n);

          Check if: SYSTEM_MEMCMP

To use the implementation of `op_memcmp` in core you do:

    #define SYSTEM_MEMCMP NO

if, you prefer to use the implementation on your platform and say it's name is `memcmp`, you do:

    #define SYSTEM_MEMCMP YES
    #define op_memcmp memcmp

## How does the SYSTEM system get the product's system settings?

Each product must either define PRODUCT_SYSTEM_FILE to the file to be used or change system.txt and add a PRODUCT_SYSTEM_FILE-row at the top.
Then, the file is simply included like this:

    #include PRODUCT_SYSTEM_FILE