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