2 Copyright (C) 1996-1997 Id Software, Inc.
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 See the GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 // sys.h -- non-portable functions
28 /* Preprocessor macros to identify platform
29 DP_OS_NAME - "friendly" name of the OS, for humans to read
30 DP_OS_STR - "identifier" of the OS, more suited for code to use
31 DP_ARCH_STR - "identifier" of the processor architecture
33 #if defined(__ANDROID__) /* must come first because it also defines linux */
34 # define DP_OS_NAME "Android"
35 # define DP_OS_STR "android"
38 # define LINK_TO_ZLIB 1
39 # define LINK_TO_LIBVORBIS 1
41 # define LINK_TO_LIBXMP 1 // nyov: if someone can test with the android NDK compiled libxmp?
43 # define DP_MOBILETOUCH 1
44 # define DP_FREETYPE_STATIC 1
45 #elif TARGET_OS_IPHONE /* must come first because it also defines MACOSX */
46 # define DP_OS_NAME "iPhoneOS"
47 # define DP_OS_STR "iphoneos"
49 # define LINK_TO_ZLIB 1
50 # define LINK_TO_LIBVORBIS 1
51 # define DP_MOBILETOUCH 1
52 # define DP_FREETYPE_STATIC 1
53 #elif defined(__linux__)
54 # define DP_OS_NAME "Linux"
55 # define DP_OS_STR "linux"
57 # define DP_OS_NAME "Windows64"
58 # define DP_OS_STR "win64"
60 # define DP_OS_NAME "Windows"
61 # define DP_OS_STR "win32"
62 #elif defined(__FreeBSD__)
63 # define DP_OS_NAME "FreeBSD"
64 # define DP_OS_STR "freebsd"
65 #elif defined(__NetBSD__)
66 # define DP_OS_NAME "NetBSD"
67 # define DP_OS_STR "netbsd"
68 #elif defined(__OpenBSD__)
69 # define DP_OS_NAME "OpenBSD"
70 # define DP_OS_STR "openbsd"
71 #elif defined(__DragonFly__)
72 # define DP_OS_NAME "DragonFlyBSD"
73 # define DP_OS_STR "dragonflybsd"
75 # define DP_OS_NAME "Mac OS X"
76 # define DP_OS_STR "osx"
77 #elif defined(__MORPHOS__)
78 # define DP_OS_NAME "MorphOS"
79 # define DP_OS_STR "morphos"
80 #elif defined (sun) || defined (__sun)
81 # if defined (__SVR4) || defined (__svr4__)
82 # define DP_OS_NAME "Solaris"
83 # define DP_OS_STR "solaris"
85 # define DP_OS_NAME "SunOS"
86 # define DP_OS_STR "sunos"
89 # define DP_OS_NAME "Unknown"
90 # define DP_OS_STR "unknown"
93 #if defined(__GNUC__) || (__clang__)
94 # if defined(__i386__)
95 # define DP_ARCH_STR "686"
101 # define SSE2_PRESENT
103 # elif defined(__x86_64__)
104 # define DP_ARCH_STR "x86_64"
106 # define SSE2_PRESENT
107 # elif defined(__powerpc__)
108 # define DP_ARCH_STR "ppc"
110 #elif defined(_WIN64)
111 # define DP_ARCH_STR "x86_64"
113 # define SSE2_PRESENT
115 # define DP_ARCH_STR "x86"
116 # define SSE_POSSIBLE
120 # define SSE_POSSIBLE
130 // runtime detection of SSE/SSE2 capabilities for x86
131 qbool Sys_HaveSSE(void);
132 qbool Sys_HaveSSE2(void);
134 #define Sys_HaveSSE() false
135 #define Sys_HaveSSE2() false
151 extern struct cvar_s sys_usenoclockbutbenchmark;
159 # include <windows.h>
160 typedef HMODULE dllhandle_t;
164 typedef void* dllhandle_t;
167 typedef struct dllfunction_s
174 qbool Sys_LoadSelf(dllhandle_t *handle);
177 * \param dllnames a NULL terminated array of possible names for the DLL you want to load.
181 qbool Sys_LoadLibrary (const char** dllnames, dllhandle_t* handle, const dllfunction_t *fcts);
182 void Sys_FreeLibrary (dllhandle_t* handle);
183 void* Sys_GetProcAddress (dllhandle_t handle, const char* name);
185 int Sys_CheckParm (const char *parm);
187 /// called early in Host_Init
188 void Sys_InitConsole (void);
189 /// called after command system is initialized but before first Con_Print
190 void Sys_Init_Commands (void);
193 /// \returns current timestamp
194 char *Sys_TimeString(const char *timeformat);
197 // system IO interface (these are the sys functions that need to be implemented in a new driver atm)
200 /// an error will cause the entire program to exit
201 void Sys_Error (const char *error, ...) DP_FUNC_PRINTF(1) DP_FUNC_NORETURN;
203 /// (may) output text to terminal which launched program
204 void Sys_PrintToTerminal(const char *text);
205 void Sys_PrintfToTerminal(const char *fmt, ...);
207 /// INFO: This is only called by Host_Shutdown so we dont need testing for recursion
208 void Sys_Shutdown (void);
209 void Sys_Quit (int returnvalue);
211 /*! on some build/platform combinations (such as Linux gcc with the -pg
212 * profiling option) this can turn on/off profiling, used primarily to limit
213 * profiling to certain areas of the code, such as ingame performance without
214 * regard for loading/shutdown performance (-profilegameonly on commandline)
219 void Sys_AllowProfiling (qbool enable);
221 typedef struct sys_cleantime_s
223 double dirtytime; // last value gotten from Sys_DirtyTime()
224 double cleantime; // sanitized linearly increasing time since app start
228 double Sys_DirtyTime(void);
230 void Sys_ProvideSelfFD (void);
232 char *Sys_ConsoleInput (void);
234 /// called to yield for a little bit so as not to hog cpu when paused or debugging
235 void Sys_Sleep(int microseconds);
237 /// Perform Key_Event () callbacks until the input que is empty
238 void Sys_SendKeyEvents (void);
240 char *Sys_GetClipboardData (void);
242 extern qbool sys_supportsdlgetticks;
243 unsigned int Sys_SDL_GetTicks (void); // wrapper to call SDL_GetTicks
244 void Sys_SDL_Delay (unsigned int milliseconds); // wrapper to call SDL_Delay
246 /// called to set process priority for dedicated servers
247 void Sys_InitProcessNice (void);
248 void Sys_MakeProcessNice (void);
249 void Sys_MakeProcessMean (void);