Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use POSIX instead of __LINUX__ for general OS checks #492

Merged
merged 4 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ message("SDL2 Include Dir is ${SDL2_INCLUDE_DIR} ${SDL2_INCLUDE_DIRS}")

if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
message("Building for Linux")
add_compile_definitions(__LINUX__ _USE_OGL_ACTIVE_TEXTURES PRIMARY_HOG=\"d3-linux.hog\")
add_compile_definitions(POSIX __LINUX__ _USE_OGL_ACTIVE_TEXTURES PRIMARY_HOG=\"d3-linux.hog\")
set(PLATFORM_INCLUDES "lib/linux" ${SDL2_INCLUDE_DIR} ${SDL2_INCLUDE_DIRS})
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
message("Building for MAC OSX")
add_compile_definitions(__LINUX__ MACOSX=1 _USE_OGL_ACTIVE_TEXTURES PRIMARY_HOG=\"d3-osx.hog\")
add_compile_definitions(POSIX MACOSX=1 _USE_OGL_ACTIVE_TEXTURES PRIMARY_HOG=\"d3-osx.hog\")
set(PLATFORM_INCLUDES "lib/linux" ${SDL2_INCLUDE_DIR} ${SDL2_INCLUDE_DIRS})
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
# Windows.h defines to avoid as many issues as possible.
Expand Down
2 changes: 1 addition & 1 deletion Descent3/BriefingParse.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
#ifndef __BRIEFPARSE_H_
#define __BRIEFPARSE_H_

#if defined(__LINUX__)
#if defined(POSIX)
#include "linux_fix.h" //for stricmp
#endif

Expand Down
2 changes: 1 addition & 1 deletion Descent3/ConfigItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@

#include "newui.h"

#if defined(__LINUX__)
#if defined(POSIX)
void CIListBoxCallback(int ID, void *);
void CISliderCallback(int ID, void *);
#endif
Expand Down
2 changes: 1 addition & 1 deletion Descent3/Game2DLL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ struct game_api {
tOSIRISModuleInit *osiris_functions;
};
// The exported DLL function call prototypes
#if defined(__LINUX__)
#if defined(POSIX)
typedef void DLLFUNCCALL (*DLLGameCall_fp)(int eventnum, dllinfo *data);
typedef void DLLFUNCCALL (*DLLGameInit_fp)(int *api_func, uint8_t *all_ok, int num_teams_to_use);
typedef void DLLFUNCCALL (*DLLGameClose_fp)();
Expand Down
2 changes: 1 addition & 1 deletion Descent3/LoadLevel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3240,7 +3240,7 @@ void ReadTerrainSkyAndLightChunk(CFILE *fp, int version) {

Terrain_sky.flags = cf_ReadInt(fp);

#ifdef __LINUX__
#if defined(POSIX)
if (FindArg("-noterrainfog") > 0) {
Terrain_sky.flags &= ~TF_FOG;
}
Expand Down
8 changes: 4 additions & 4 deletions Descent3/Mission.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1694,12 +1694,12 @@ void InitLevelScript() {
ddio_SplitPath(Current_level->filename, NULL, filename, ext);
#if defined(WIN32)
strcat(filename, ".dll");
#else
#if defined(MACOSX)
#elif defined(MACOSX)
strcat(filename, ".dylib");
#else
#elif defined(__LINUX__)
strcat(filename, ".so");
#endif
#else
#error Unsupported platform!
#endif
Osiris_LoadLevelModule(filename);
}
Expand Down
11 changes: 5 additions & 6 deletions Descent3/OsirisLoadandBind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ bool Show_osiris_debug = false;
// 0, only when the level ends

// The exported DLL function call prototypes
#if defined(__LINUX__)
#if defined(POSIX)
typedef char DLLFUNCCALL (*InitializeDLL_fp)(tOSIRISModuleInit *function_list);
typedef void DLLFUNCCALL (*ShutdownDLL_fp)(void);
typedef int DLLFUNCCALL (*GetGOScriptID_fp)(const char *name, uint8_t isdoor);
Expand Down Expand Up @@ -3144,14 +3144,14 @@ int Osiris_ExtractScriptsFromHog(int library_handle, bool is_mission_hog) {
int count = 0;

const char *script_extension;
#if defined(__LINUX__)
#if defined(MACOSX)
script_extension = "*.dylib";
#else
#elif defined(__LINUX__)
script_extension = "*.so";
#endif
#else
#elif defined(WIN32)
script_extension = "*.dll";
#else
#error Unsupported platform!
#endif

int index;
Expand Down Expand Up @@ -4037,4 +4037,3 @@ void Osiris_CreateModuleInitStruct(tOSIRISModuleInit *mi) {
mi->fp[i] = NULL;
}
}

8 changes: 4 additions & 4 deletions Descent3/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ struct video_menu {
sheet->AddLongRadioButton("1600x1200");
*resolution = iTemp;

#if !defined(__LINUX__)
#if !defined(POSIX)
// renderer bit depth
switch (Render_preferred_bitdepth) {
case 16:
Expand Down Expand Up @@ -708,7 +708,7 @@ struct video_menu {

sheet->NewGroup(TXT_MONITOR, 0, 180);
vsync = sheet->AddLongCheckBox(TXT_CFG_VSYNCENABLED, (Render_preferred_state.vsync_on != 0));
#ifndef __LINUX__
#if !defined(POSIX)
sheet->AddText("");
sheet->AddLongButton(TXT_AUTO_GAMMA, IDV_AUTOGAMMA);
#endif
Expand All @@ -723,7 +723,7 @@ struct video_menu {
Render_preferred_state.mipping = (*mipmapping) ? 1 : 0;
if (vsync)
Render_preferred_state.vsync_on = (*vsync) ? 1 : 0;
#if !defined(__LINUX__)
#if !defined(POSIX)
if (bitdepth)
Render_preferred_bitdepth = (*bitdepth) == 1 ? 32 : 16;
#endif
Expand Down Expand Up @@ -753,7 +753,7 @@ struct video_menu {

// process
void process(int res) {
#ifndef __LINUX__
#if !defined(POSIX)
switch (res) {
case IDV_AUTOGAMMA:
config_gamma();
Expand Down
2 changes: 1 addition & 1 deletion Descent3/credits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
#include <math.h>
#include "psrand.h"

#if defined(__LINUX__)
#if defined(POSIX)
#include "linux_fix.h"
#endif

Expand Down
4 changes: 2 additions & 2 deletions Descent3/dedicated_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
#include <string.h>
#include <stdlib.h>

#ifndef __LINUX__
#if !defined(POSIX)
typedef int socklen_t;
#endif

Expand Down Expand Up @@ -788,7 +788,7 @@ void PrintDedicatedMessage(const char *fmt, ...) {
DedicatedSocketputs(buf);
}

#ifdef __LINUX__
#if defined(POSIX)
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/socket.h>
Expand Down
2 changes: 1 addition & 1 deletion Descent3/gamesave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ struct tLoadGameDialogData {
chunked_bitmap chunk;
};

#if defined(__LINUX__)
#if defined(POSIX)
void LoadGameDialogCB(newuiTiledWindow *wnd, void *data)
#else
void __cdecl LoadGameDialogCB(newuiTiledWindow *wnd, void *data)
Expand Down
2 changes: 1 addition & 1 deletion Descent3/matcen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1904,7 +1904,7 @@ void InitMatcens() {
atexit(DestroyAllMatcens);
}

#if defined(__LINUX__)
#if defined(POSIX)
void DestroyAllMatcens()
#else
void __cdecl DestroyAllMatcens()
Expand Down
2 changes: 1 addition & 1 deletion Descent3/mission_download.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@ int msn_ExtractZipFile(char *zipfilename, char *mn3name) {
return 1;
}

#ifdef __LINUX__
#if defined(POSIX)
char *_strlwr(char *string) {
char *ptr = string;
while (*ptr) {
Expand Down
4 changes: 2 additions & 2 deletions Descent3/mmItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ enum tmmItemFX {
void MenuScene(); // display menu scene
/////////////////////////////////////////////////////////////////////
// gcc doesn't like the tQueue template in psclass.h
#ifdef __LINUX__
#if defined(POSIX)
// tQueue
// a circular queue implementation
class tmmItemQueue {
Expand Down Expand Up @@ -144,7 +144,7 @@ class mmItem : public UIGadget {
int16_t m_alpha; // alpha for text item
int16_t m_satcount;
tmmItemFX m_curfx; // current effect
#ifndef __LINUX__
#if !defined(POSIX)
tQueue<tmmItemFX, 8> m_fxqueue; // special effects queue
#else
tmmItemQueue m_fxqueue;
Expand Down
2 changes: 1 addition & 1 deletion Descent3/multi.h
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@
#include "object_external.h"
#include "player_external.h"

#if defined(__LINUX__)
#if defined(POSIX)
#include "linux_fix.h"
#endif

Expand Down
2 changes: 1 addition & 1 deletion Descent3/multi_dll_mgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ extern bool Multi_Gamelist_changed;
int CheckMissionForScript(char *mission, char *script, int dedicated_server_num_teams);
void ShowNetgameInfo(network_game *game);
// The exported DLL function call prototypes
#if defined(__LINUX__)
#if defined(POSIX)
typedef void DLLFUNCCALL (*DLLMultiCall_fp)(int eventnum);
typedef void DLLFUNCCALL (*DLLMultiScoreCall_fp)(int eventnum, void *data);
typedef void DLLFUNCCALL (*DLLMultiInit_fp)(int *api_fp);
Expand Down
2 changes: 1 addition & 1 deletion Descent3/multi_external.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
#ifndef __MULTI_EXTERNAL_H_
#define __MULTI_EXTERNAL_H_

#if defined(__LINUX__)
#if defined(POSIX)
#include <cstring>
#include <cstdint>
typedef uintptr_t DWORD;
Expand Down
2 changes: 1 addition & 1 deletion Descent3/newui.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@
#ifndef NEWUI_H
#define NEWUI_H

#if defined(__LINUX__)
#if defined(POSIX)
#include "linux_fix.h" //fix some of the stricmp's
#endif

Expand Down
6 changes: 3 additions & 3 deletions Descent3/sdlmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,13 @@ void just_exit(void) {
#endif

SDL_Quit();
#ifdef __LINUX__
#if defined(POSIX)
sync(); // just in case.
#endif
_exit(0);
}

#ifdef __LINUX__
#if defined(POSIX)
void fatal_signal_handler(int signum) {
switch (signum) {
case SIGHUP:
Expand Down Expand Up @@ -612,7 +612,7 @@ int main(int argc, char *argv[]) {
}

bool run_d3 = true;
#ifdef __LINUX__
#if defined(POSIX)
if (flags & APPFLAG_USESERVICE) {
run_d3 = false;
pid_t np = fork();
Expand Down
2 changes: 1 addition & 1 deletion Descent3/terrainrender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2717,7 +2717,7 @@ static g3Point *slist[256];
// Draws the 2 triangles of the Terrainlist[index] (software)
int DrawTerrainTrianglesSoftware(int index, int bm_handle, int upper_left, int lower_right) {
/*
#ifndef __LINUX__
#if !defined(POSIX)
int i,tlist[4],close=0,lit=0;
float closest_z=9999;
int color;
Expand Down
2 changes: 1 addition & 1 deletion bitmap/lightmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include "bitmap.h"
#include "mono.h"
#include "mem.h"
#ifndef __LINUX__
#if !defined(POSIX)
#include "Macros.h"
#endif

Expand Down
4 changes: 2 additions & 2 deletions cfile/cfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include <memory>
#include <vector>

#ifndef __LINUX__
#if !defined(POSIX)
// Non-Linux Build Includes
#include <io.h>
#else
Expand Down Expand Up @@ -425,7 +425,7 @@ CFILE *open_file_in_directory(const std::filesystem::path &filename, const char
fp = fopen(using_filename.u8string().c_str(), tmode);

if (!fp) {
#ifdef __LINUX__
#if defined(POSIX)
// If we tried to open file for reading, assume there maybe case-sensitive files
if (tmode[0] == 'r') {
// Try different cases of the filename
Expand Down
4 changes: 2 additions & 2 deletions ddebug/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
#define IDNO 7
#endif
// #define DEBUG_LEVEL 0 //DAJ
#if defined(WIN32) || defined(__LINUX__)
#if defined(WIN32) || defined(POSIX)
constexpr const int OSMBOX_OK = 1;
constexpr const int OSMBOX_YESNO = 2;
constexpr const int OSMBOX_YESNOCANCEL = 3;
Expand Down Expand Up @@ -172,7 +172,7 @@ void Debug_ConsolePrintfAt(int n, int row, int col, const char *format, ...);
#if !defined(RELEASE)
#include "debugbreak.h"
#if defined(WIN32)
#elif defined(__LINUX__)
#elif defined(POSIX)
void ddio_InternalKeyClose();
#else
#define debug_break()
Expand Down
2 changes: 1 addition & 1 deletion legacy/briefinglocalizer/briefinglocalizerDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "briefinglocalizer.h"
#include "briefinglocalizerDlg.h"

#ifdef __LINUX__
#if defined(POSIX)
#include "linux_fix.h"
#endif

Expand Down
Loading