xref: /netbsd-src/external/gpl3/gcc/dist/libphobos/src/std/system.d (revision b1e838363e3c6fc78a55519254d99869742dd33c)
1181254a7Smrg // Written in the D programming language.
2181254a7Smrg 
3181254a7Smrg /**
4181254a7Smrg  * Information about the target operating system, environment, and CPU.
5181254a7Smrg  *
6*b1e83836Smrg  *  Copyright: Copyright The D Language Foundation 2000 - 2011
7181254a7Smrg  *  License:   $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
8*b1e83836Smrg  *  Authors:   $(HTTP digitalmars.com, Walter Bright) and
9*b1e83836Smrg                $(HTTP jmdavisprog.com, Jonathan M Davis)
10*b1e83836Smrg  *  Source:    $(PHOBOSSRC std/system.d)
11181254a7Smrg  */
12181254a7Smrg module std.system;
13181254a7Smrg 
14181254a7Smrg immutable
15181254a7Smrg {
16181254a7Smrg     /++
17181254a7Smrg         Operating system.
18181254a7Smrg 
19181254a7Smrg         Note:
20181254a7Smrg             This is for cases where you need a value representing the OS at
21181254a7Smrg             runtime. If you're doing something which should compile differently
22*b1e83836Smrg             on different OSes, then please use `version (Windows)`,
23*b1e83836Smrg             `version (linux)`, etc.
24181254a7Smrg 
25181254a7Smrg         See_Also:
26181254a7Smrg             $(DDSUBLINK spec/version,PredefinedVersions, Predefined Versions)
27181254a7Smrg       +/
28181254a7Smrg     enum OS
29181254a7Smrg     {
30181254a7Smrg         win32 = 1, /// Microsoft 32 bit Windows systems
31181254a7Smrg         win64,     /// Microsoft 64 bit Windows systems
32181254a7Smrg         linux,     /// All Linux Systems, except for Android
33181254a7Smrg         osx,       /// Mac OS X
34*b1e83836Smrg         iOS,       /// iOS
35*b1e83836Smrg         tvOS,      /// tvOS
36*b1e83836Smrg         watchOS,   /// watchOS
37181254a7Smrg         freeBSD,   /// FreeBSD
38181254a7Smrg         netBSD,    /// NetBSD
39*b1e83836Smrg         openBSD,   /// OpenBSD
40181254a7Smrg         dragonFlyBSD, /// DragonFlyBSD
41181254a7Smrg         solaris,   /// Solaris
42181254a7Smrg         android,   /// Android
43*b1e83836Smrg         otherPosix, /// Other Posix Systems
44*b1e83836Smrg         unknown,   /// Unknown
45181254a7Smrg     }
46181254a7Smrg 
47181254a7Smrg     /// The OS that the program was compiled for.
48181254a7Smrg     version (Win32)        OS os = OS.win32;
49181254a7Smrg     else version (Win64)   OS os = OS.win64;
50181254a7Smrg     else version (Android) OS os = OS.android;
51181254a7Smrg     else version (linux)   OS os = OS.linux;
52181254a7Smrg     else version (OSX)     OS os = OS.osx;
53*b1e83836Smrg     else version (iOS)     OS os = OS.iOS;
54*b1e83836Smrg     else version (tvOS)    OS os = OS.tvOS;
55*b1e83836Smrg     else version (watchOS) OS os = OS.watchOS;
56181254a7Smrg     else version (FreeBSD) OS os = OS.freeBSD;
57181254a7Smrg     else version (NetBSD)  OS os = OS.netBSD;
58*b1e83836Smrg     else version (OpenBSD) OS os = OS.openBSD;
59181254a7Smrg     else version (DragonFlyBSD) OS os = OS.dragonFlyBSD;
60181254a7Smrg     else version (Posix)   OS os = OS.otherPosix;
61*b1e83836Smrg     else OS os = OS.unknown;
62181254a7Smrg 
63181254a7Smrg     /++
64181254a7Smrg         Byte order endianness.
65181254a7Smrg 
66181254a7Smrg         Note:
67181254a7Smrg             This is intended for cases where you need to deal with endianness at
68181254a7Smrg             runtime. If you're doing something which should compile differently
69181254a7Smrg             depending on whether you're compiling on a big endian or little
70*b1e83836Smrg             endian machine, then please use `version (BigEndian)` and
71*b1e83836Smrg             `version (LittleEndian)`.
72181254a7Smrg 
73181254a7Smrg         See_Also:
74181254a7Smrg             $(DDSUBLINK spec/version,PredefinedVersions, Predefined Versions)
75181254a7Smrg       +/
76181254a7Smrg     enum Endian
77181254a7Smrg     {
78181254a7Smrg         bigEndian,   /// Big endian byte order
79181254a7Smrg         littleEndian /// Little endian byte order
80181254a7Smrg     }
81181254a7Smrg 
82181254a7Smrg     /// The endianness that the program was compiled for.
83181254a7Smrg     version (LittleEndian) Endian endian = Endian.littleEndian;
84181254a7Smrg     else                  Endian endian = Endian.bigEndian;
85181254a7Smrg }
86181254a7Smrg 
87