1 // Written in the D programming language.
2 
3 /**
4  * Information about the target operating system, environment, and CPU.
5  *
6  *  Copyright: Copyright The D Language Foundation 2000 - 2011
7  *  License:   $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
8  *  Authors:   $(HTTP digitalmars.com, Walter Bright) and
9                $(HTTP jmdavisprog.com, Jonathan M Davis)
10  *  Source:    $(PHOBOSSRC std/system.d)
11  */
12 module std.system;
13 
14 immutable
15 {
16     /++
17         Operating system.
18 
19         Note:
20             This is for cases where you need a value representing the OS at
21             runtime. If you're doing something which should compile differently
22             on different OSes, then please use `version (Windows)`,
23             `version (linux)`, etc.
24 
25         See_Also:
26             $(DDSUBLINK spec/version,PredefinedVersions, Predefined Versions)
27       +/
28     enum OS
29     {
30         win32 = 1, /// Microsoft 32 bit Windows systems
31         win64,     /// Microsoft 64 bit Windows systems
32         linux,     /// All Linux Systems, except for Android
33         osx,       /// Mac OS X
34         iOS,       /// iOS
35         tvOS,      /// tvOS
36         watchOS,   /// watchOS
37         freeBSD,   /// FreeBSD
38         netBSD,    /// NetBSD
39         dragonFlyBSD, /// DragonFlyBSD
40         solaris,   /// Solaris
41         android,   /// Android
42         otherPosix, /// Other Posix Systems
43         unknown,   /// Unknown
44     }
45 
46     /// The OS that the program was compiled for.
47     version (Win32)        OS os = OS.win32;
48     else version (Win64)   OS os = OS.win64;
49     else version (Android) OS os = OS.android;
50     else version (linux)   OS os = OS.linux;
51     else version (OSX)     OS os = OS.osx;
52     else version (iOS)     OS os = OS.iOS;
53     else version (tvOS)    OS os = OS.tvOS;
54     else version (watchOS) OS os = OS.watchOS;
55     else version (FreeBSD) OS os = OS.freeBSD;
56     else version (NetBSD)  OS os = OS.netBSD;
57     else version (DragonFlyBSD) OS os = OS.dragonFlyBSD;
58     else version (Posix)   OS os = OS.otherPosix;
59     else OS os = OS.unknown;
60 
61     /++
62         Byte order endianness.
63 
64         Note:
65             This is intended for cases where you need to deal with endianness at
66             runtime. If you're doing something which should compile differently
67             depending on whether you're compiling on a big endian or little
68             endian machine, then please use `version (BigEndian)` and
69             `version (LittleEndian)`.
70 
71         See_Also:
72             $(DDSUBLINK spec/version,PredefinedVersions, Predefined Versions)
73       +/
74     enum Endian
75     {
76         bigEndian,   /// Big endian byte order
77         littleEndian /// Little endian byte order
78     }
79 
80     /// The endianness that the program was compiled for.
81     version (LittleEndian) Endian endian = Endian.littleEndian;
82     else                  Endian endian = Endian.bigEndian;
83 }
84 
85