From 2fa63ca01586c4e5fda8eb12dca444d47a2375f1 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Tue, 3 May 2011 14:30:25 +0200 Subject: COMMON: Forbid use of getcwd&getwd; add macro to enable unistd.h compatibility --- backends/fs/n64/n64-fs.cpp | 2 + backends/fs/posix/posix-fs-factory.cpp | 3 +- backends/fs/posix/posix-fs.cpp | 5 +- backends/fs/psp/psp-fs-factory.cpp | 4 +- backends/fs/psp/psp-fs.cpp | 6 +- backends/fs/wii/wii-fs.cpp | 4 +- backends/platform/dc/dc-fs.cpp | 4 +- backends/platform/ps2/savefilemgr.cpp | 3 +- backends/platform/samsungtv/main.cpp | 2 + backends/platform/webos/main.cpp | 2 + backends/platform/wii/main.cpp | 1 + common/forbidden.h | 132 +++++++++++++++++++-------------- engines/engine.cpp | 2 + 13 files changed, 94 insertions(+), 76 deletions(-) diff --git a/backends/fs/n64/n64-fs.cpp b/backends/fs/n64/n64-fs.cpp index 75c1e0bea0..a56a4947e8 100644 --- a/backends/fs/n64/n64-fs.cpp +++ b/backends/fs/n64/n64-fs.cpp @@ -22,6 +22,8 @@ #ifdef __N64__ +#define FORBIDDEN_SYMBOL_EXCEPTION_unistd_h + #include "backends/fs/n64/n64-fs.h" #include "backends/fs/n64/romfsstream.h" diff --git a/backends/fs/posix/posix-fs-factory.cpp b/backends/fs/posix/posix-fs-factory.cpp index a69cf6b3b4..a82b176daf 100644 --- a/backends/fs/posix/posix-fs-factory.cpp +++ b/backends/fs/posix/posix-fs-factory.cpp @@ -25,9 +25,8 @@ #if defined(UNIX) // Re-enable some forbidden symbols to avoid clashes with stat.h and unistd.h. -#define FORBIDDEN_SYMBOL_EXCEPTION_chdir +#define FORBIDDEN_SYMBOL_EXCEPTION_unistd_h #define FORBIDDEN_SYMBOL_EXCEPTION_mkdir -#define FORBIDDEN_SYMBOL_EXCEPTION_unlink #include "backends/fs/posix/posix-fs-factory.h" #include "backends/fs/posix/posix-fs.h" diff --git a/backends/fs/posix/posix-fs.cpp b/backends/fs/posix/posix-fs.cpp index 7aa17e5cc1..26b4464bb4 100644 --- a/backends/fs/posix/posix-fs.cpp +++ b/backends/fs/posix/posix-fs.cpp @@ -24,10 +24,9 @@ #if defined(UNIX) -// Re-enable some forbidden symbols to avoid clashes with stat.h and unistd.h. -#define FORBIDDEN_SYMBOL_EXCEPTION_chdir +// Re-enable some forbidden symbols to avoid clashes with stat.h and unistd.h. +#define FORBIDDEN_SYMBOL_EXCEPTION_unistd_h #define FORBIDDEN_SYMBOL_EXCEPTION_mkdir -#define FORBIDDEN_SYMBOL_EXCEPTION_unlink #include "backends/fs/posix/posix-fs.h" #include "backends/fs/stdiostream.h" diff --git a/backends/fs/psp/psp-fs-factory.cpp b/backends/fs/psp/psp-fs-factory.cpp index 6b0364b57e..aee541d12a 100644 --- a/backends/fs/psp/psp-fs-factory.cpp +++ b/backends/fs/psp/psp-fs-factory.cpp @@ -38,9 +38,7 @@ // for the PSP port #define FORBIDDEN_SYMBOL_EXCEPTION_printf -// Avoid clashes with unistd.h -#define FORBIDDEN_SYMBOL_EXCEPTION_chdir -#define FORBIDDEN_SYMBOL_EXCEPTION_unlink +#define FORBIDDEN_SYMBOL_EXCEPTION_unistd_h #include "backends/fs/psp/psp-fs-factory.h" #include "backends/fs/psp/psp-fs.h" diff --git a/backends/fs/psp/psp-fs.cpp b/backends/fs/psp/psp-fs.cpp index b36b7a017c..908430b2f9 100644 --- a/backends/fs/psp/psp-fs.cpp +++ b/backends/fs/psp/psp-fs.cpp @@ -40,11 +40,9 @@ #define FORBIDDEN_SYMBOL_EXCEPTION_time_h -#define FORBIDDEN_SYMBOL_EXCEPTION_mkdir +#define FORBIDDEN_SYMBOL_EXCEPTION_unistd_h -// Avoid clashes with unistd.h -#define FORBIDDEN_SYMBOL_EXCEPTION_chdir -#define FORBIDDEN_SYMBOL_EXCEPTION_unlink +#define FORBIDDEN_SYMBOL_EXCEPTION_mkdir #include "backends/fs/psp/psp-fs.h" #include "backends/fs/psp/psp-stream.h" diff --git a/backends/fs/wii/wii-fs.cpp b/backends/fs/wii/wii-fs.cpp index 74c7cf944c..eb631df1bf 100644 --- a/backends/fs/wii/wii-fs.cpp +++ b/backends/fs/wii/wii-fs.cpp @@ -23,9 +23,9 @@ #if defined(__WII__) #define FORBIDDEN_SYMBOL_EXCEPTION_time_h -#define FORBIDDEN_SYMBOL_EXCEPTION_chdir +#define FORBIDDEN_SYMBOL_EXCEPTION_unistd_h + #define FORBIDDEN_SYMBOL_EXCEPTION_mkdir -#define FORBIDDEN_SYMBOL_EXCEPTION_unlink #include "backends/fs/wii/wii-fs.h" #include "backends/fs/wii/wii-fs-factory.h" diff --git a/backends/platform/dc/dc-fs.cpp b/backends/platform/dc/dc-fs.cpp index e07dfbfd9b..a024b5d70d 100644 --- a/backends/platform/dc/dc-fs.cpp +++ b/backends/platform/dc/dc-fs.cpp @@ -22,9 +22,7 @@ * $Id$ */ -// Avoid clashes with unistd.h -#define FORBIDDEN_SYMBOL_EXCEPTION_chdir -#define FORBIDDEN_SYMBOL_EXCEPTION_unlink +#define FORBIDDEN_SYMBOL_EXCEPTION_unistd_h #include "dc.h" #include "backends/fs/abstract-fs.h" diff --git a/backends/platform/ps2/savefilemgr.cpp b/backends/platform/ps2/savefilemgr.cpp index 871ce11ef6..010357c61c 100644 --- a/backends/platform/ps2/savefilemgr.cpp +++ b/backends/platform/ps2/savefilemgr.cpp @@ -24,8 +24,7 @@ */ #define FORBIDDEN_SYMBOL_EXCEPTION_printf -#define FORBIDDEN_SYMBOL_EXCEPTION_chdir -#define FORBIDDEN_SYMBOL_EXCEPTION_mkdir +#define FORBIDDEN_SYMBOL_EXCEPTION_unistd_h #include "common/config-manager.h" #include "common/zlib.h" diff --git a/backends/platform/samsungtv/main.cpp b/backends/platform/samsungtv/main.cpp index 3beb97165f..a1962dd904 100644 --- a/backends/platform/samsungtv/main.cpp +++ b/backends/platform/samsungtv/main.cpp @@ -23,6 +23,8 @@ * */ +#define FORBIDDEN_SYMBOL_EXCEPTION_unistd_h + #include "backends/platform/samsungtv/samsungtv.h" #include "backends/plugins/sdl/sdl-provider.h" #include "base/main.h" diff --git a/backends/platform/webos/main.cpp b/backends/platform/webos/main.cpp index bbf55c6efd..eefdd30496 100644 --- a/backends/platform/webos/main.cpp +++ b/backends/platform/webos/main.cpp @@ -23,6 +23,8 @@ * */ +#define FORBIDDEN_SYMBOL_EXCEPTION_unistd_h + #include "backends/platform/webos/webos.h" #include "backends/plugins/sdl/sdl-provider.h" #include "base/main.h" diff --git a/backends/platform/wii/main.cpp b/backends/platform/wii/main.cpp index 959931de00..3965f51b7f 100644 --- a/backends/platform/wii/main.cpp +++ b/backends/platform/wii/main.cpp @@ -20,6 +20,7 @@ */ #define FORBIDDEN_SYMBOL_EXCEPTION_chdir +#define FORBIDDEN_SYMBOL_EXCEPTION_getcwd #define FORBIDDEN_SYMBOL_EXCEPTION_printf #include diff --git a/common/forbidden.h b/common/forbidden.h index c22c646b79..af22b2ee21 100644 --- a/common/forbidden.h +++ b/common/forbidden.h @@ -144,68 +144,91 @@ #endif +// // Disable various symbols from time.h +// #ifndef FORBIDDEN_SYMBOL_EXCEPTION_time_h -/* -#ifndef FORBIDDEN_SYMBOL_EXCEPTION_time_t -#undef time_t -#define time_t FORBIDDEN_SYMBOL_REPLACEMENT -#endif -*/ - -#ifndef FORBIDDEN_SYMBOL_EXCEPTION_asctime -#undef asctime -#define asctime(a) FORBIDDEN_SYMBOL_REPLACEMENT -#endif - -#ifndef FORBIDDEN_SYMBOL_EXCEPTION_clock -#undef clock -#define clock() FORBIDDEN_SYMBOL_REPLACEMENT -#endif - -#ifndef FORBIDDEN_SYMBOL_EXCEPTION_ctime -#undef ctime -#define ctime(a) FORBIDDEN_SYMBOL_REPLACEMENT -#endif - -#ifndef FORBIDDEN_SYMBOL_EXCEPTION_difftime -#undef difftime -#define difftime(a,b) FORBIDDEN_SYMBOL_REPLACEMENT -#endif + /* + #ifndef FORBIDDEN_SYMBOL_EXCEPTION_time_t + #undef time_t + #define time_t FORBIDDEN_SYMBOL_REPLACEMENT + #endif + */ + + #ifndef FORBIDDEN_SYMBOL_EXCEPTION_asctime + #undef asctime + #define asctime(a) FORBIDDEN_SYMBOL_REPLACEMENT + #endif + + #ifndef FORBIDDEN_SYMBOL_EXCEPTION_clock + #undef clock + #define clock() FORBIDDEN_SYMBOL_REPLACEMENT + #endif + + #ifndef FORBIDDEN_SYMBOL_EXCEPTION_ctime + #undef ctime + #define ctime(a) FORBIDDEN_SYMBOL_REPLACEMENT + #endif + + #ifndef FORBIDDEN_SYMBOL_EXCEPTION_difftime + #undef difftime + #define difftime(a,b) FORBIDDEN_SYMBOL_REPLACEMENT + #endif + + #ifndef FORBIDDEN_SYMBOL_EXCEPTION_getdate + #undef getdate + #define getdate(a) FORBIDDEN_SYMBOL_REPLACEMENT + #endif + + #ifndef FORBIDDEN_SYMBOL_EXCEPTION_gmtime + #undef gmtime + #define gmtime(a) FORBIDDEN_SYMBOL_REPLACEMENT + #endif + + #ifndef FORBIDDEN_SYMBOL_EXCEPTION_localtime + #undef localtime + #define localtime(a) FORBIDDEN_SYMBOL_REPLACEMENT + #endif + + #ifndef FORBIDDEN_SYMBOL_EXCEPTION_mktime + #undef mktime + #define mktime(a) FORBIDDEN_SYMBOL_REPLACEMENT + #endif + + #ifndef FORBIDDEN_SYMBOL_EXCEPTION_time + #undef time + #define time(a) FORBIDDEN_SYMBOL_REPLACEMENT + #endif -#ifndef FORBIDDEN_SYMBOL_EXCEPTION_getdate -#undef getdate -#define getdate(a) FORBIDDEN_SYMBOL_REPLACEMENT -#endif +#endif // FORBIDDEN_SYMBOL_EXCEPTION_time_h -#ifndef FORBIDDEN_SYMBOL_EXCEPTION_gmtime -#undef gmtime -#define gmtime(a) FORBIDDEN_SYMBOL_REPLACEMENT -#endif +// +// Disable various symbols from unistd.h +// +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_unistd_h -#ifndef FORBIDDEN_SYMBOL_EXCEPTION_localtime -#undef localtime -#define localtime(a) FORBIDDEN_SYMBOL_REPLACEMENT -#endif + #ifndef FORBIDDEN_SYMBOL_EXCEPTION_chdir + #undef chdir + #define chdir(a) FORBIDDEN_SYMBOL_REPLACEMENT + #endif -#ifndef FORBIDDEN_SYMBOL_EXCEPTION_mktime -#undef mktime -#define mktime(a) FORBIDDEN_SYMBOL_REPLACEMENT -#endif + #ifndef FORBIDDEN_SYMBOL_EXCEPTION_getcwd + #undef getcwd + #define getcwd(a,b) FORBIDDEN_SYMBOL_REPLACEMENT + #endif -#ifndef FORBIDDEN_SYMBOL_EXCEPTION_time -#undef time -#define time(a) FORBIDDEN_SYMBOL_REPLACEMENT -#endif - -#endif // FORBIDDEN_SYMBOL_EXCEPTION_time_h + #ifndef FORBIDDEN_SYMBOL_EXCEPTION_getwd + #undef getwd + #define getwd(a) FORBIDDEN_SYMBOL_REPLACEMENT + #endif + #ifndef FORBIDDEN_SYMBOL_EXCEPTION_unlink + #undef unlink + #define unlink(a) FORBIDDEN_SYMBOL_REPLACEMENT + #endif -#ifndef FORBIDDEN_SYMBOL_EXCEPTION_chdir -#undef chdir -#define chdir(a) FORBIDDEN_SYMBOL_REPLACEMENT -#endif +#endif // FORBIDDEN_SYMBOL_EXCEPTION_unistd_h #ifndef FORBIDDEN_SYMBOL_EXCEPTION_mkdir #undef mkdir @@ -224,11 +247,6 @@ #define setvbuf(a,b,c,d) FORBIDDEN_SYMBOL_REPLACEMENT #endif -#ifndef FORBIDDEN_SYMBOL_EXCEPTION_unlink -#undef unlink -#define unlink(a) FORBIDDEN_SYMBOL_REPLACEMENT -#endif - /* * We also would like to disable the following symbols; * however, these are also frequently used in regular code, diff --git a/engines/engine.cpp b/engines/engine.cpp index 217740d9d5..2c1d3a732c 100644 --- a/engines/engine.cpp +++ b/engines/engine.cpp @@ -22,6 +22,8 @@ * $Id$ */ +#define FORBIDDEN_SYMBOL_EXCEPTION_getcwd + #if defined(WIN32) && !defined(_WIN32_WCE) && !defined(__SYMBIAN32__) #define WIN32_LEAN_AND_MEAN #include -- cgit v1.2.3