Use __ANDROID__ to handle specific Android code

This commit is contained in:
scribam 2019-08-25 18:38:36 +02:00
parent 02b450ff19
commit 61382316c9
26 changed files with 61 additions and 61 deletions

View File

@ -72,7 +72,7 @@ namespace ImGui
}
*/
#ifdef _ANDROID
#ifdef __ANDROID__
#include <android/log.h>
#define LOG_TAG "flycast"

View File

@ -63,7 +63,7 @@ Index of this file:
#include <assert.h>
#define IM_ASSERT(_EXPR) assert(_EXPR) // You can override the default assert handler by editing imconfig.h
#endif
#if (defined(__clang__) || defined(__GNUC__)) && !defined(_ANDROID)
#if (defined(__clang__) || defined(__GNUC__)) && !defined(__ANDROID__)
#define IM_FMTARGS(FMT) __attribute__((format(printf, FMT, FMT+1))) // Apply printf-style warnings to user functions.
#define IM_FMTLIST(FMT) __attribute__((format(printf, FMT, 0)))
#else

View File

@ -35,7 +35,7 @@ extern "C" {
#define VIXL_CODE_BUFFER_MALLOC
//#define VIXL_DEBUG
#if defined(_ANDROID) && defined(VIXL_DEBUG)
#if defined(__ANDROID__) && defined(VIXL_DEBUG)
#include <android/log.h>
#ifdef printf

View File

@ -99,7 +99,7 @@ public:
Mov(ADRS_REG, 0);
Ldr(MDEC_CT, dsp_operand(&DSP->regs.MDEC_CT));
#ifndef _ANDROID
#ifndef __ANDROID__
Instruction* instr_cur = GetBuffer()->GetEndAddress<Instruction*>();
DEBUG_LOG(AICA_ARM, "DSP PROLOGUE");
Disassemble(instr_start, instr_cur);
@ -356,7 +356,7 @@ public:
Add(w1, w1, w2);
Str(w1, mem_operand);
}
#ifndef _ANDROID
#ifndef __ANDROID__
instr_cur = GetBuffer()->GetEndAddress<Instruction*>();
DEBUG_LOG(AICA_ARM, "DSP STEP %d: %04x %04x %04x %04x", step, mpro[0], mpro[1], mpro[2], mpro[3]);
Disassemble(instr_start, instr_cur);
@ -378,7 +378,7 @@ public:
Ldp(x19, x20, MemOperand(sp, 80));
Ldp(x29, x30, MemOperand(sp, 96, PostIndex));
Ret();
#ifndef _ANDROID
#ifndef __ANDROID__
instr_cur = GetBuffer()->GetEndAddress<Instruction*>();
DEBUG_LOG(AICA_ARM, "DSP EPILOGUE");
Disassemble(instr_start, instr_cur);
@ -534,7 +534,7 @@ void dsp_step()
dsp_recompile();
}
#ifdef _ANDROID
#ifdef __ANDROID__
((void (*)())&dsp.DynCode)();
#endif
}

View File

@ -31,7 +31,7 @@
#include <fcntl.h> /* For O_* constants */
#include <unistd.h>
#include <errno.h>
#ifdef _ANDROID
#ifdef __ANDROID__
#include <linux/ashmem.h>
#endif
#endif

View File

@ -555,7 +555,7 @@ void rend_start_render()
void rend_end_render()
{
#if 1 //also disabled the printf, it takes quite some time ...
#if HOST_OS!=OS_WINDOWS && !(defined(_ANDROID) || defined(TARGET_PANDORA))
#if HOST_OS!=OS_WINDOWS && !(defined(__ANDROID__) || defined(TARGET_PANDORA))
//too much console spam.
//TODO: how about a counter?
//if (!re.state) printf("Render > Extended time slice ...\n");

View File

@ -15,7 +15,7 @@ tad_context ta_tad;
TA_context* vd_ctx;
rend_context vd_rc;
#if ANDROID
#if __ANDROID__
#include <errno.h>
#include <malloc.h>

View File

@ -7,7 +7,7 @@
d) Cookies (if you're really lucky)
*/
#if HOST_CPU == CPU_ARM && !defined(_ANDROID) && 0
#if HOST_CPU == CPU_ARM && !defined(__ANDROID__) && 0
//FIXME: Fix extern function support on shil, or remove these
extern "C" void ftrv_asm(float* fd,float* fn, float* fm);
extern "C" f32 fipr_asm(float* fn, float* fm);

View File

@ -76,7 +76,7 @@ static void *get_proc(const char *proc)
CFRelease(procname);
return res;
}
#elif defined(_ANDROID)
#elif defined(__ANDROID__)
#include <dlfcn.h>
#include <EGL/egl.h>

View File

@ -88,7 +88,7 @@ static GL3WglProc get_proc(const char *proc)
*(void **)(&res) = dlsym(libgl, proc);
return res;
}
#elif defined(_ANDROID)
#elif defined(__ANDROID__)
#include <dlfcn.h>
#include <EGL/egl.h>

View File

@ -15,7 +15,7 @@
#include <signal.h>
#include <sys/param.h>
#include <sys/time.h>
#if !defined(TARGET_BSD) && !defined(_ANDROID) && !defined(TARGET_IPHONE) && !defined(TARGET_EMSCRIPTEN) && !defined(TARGET_OSX) && !defined(TARGET_OSX_X64)
#if !defined(TARGET_BSD) && !defined(__ANDROID__) && !defined(TARGET_IPHONE) && !defined(TARGET_EMSCRIPTEN) && !defined(TARGET_OSX) && !defined(TARGET_OSX_X64)
#include <sys/personality.h>
#include <dlfcn.h>
#endif
@ -175,7 +175,7 @@ void enable_runfast()
}
void linux_fix_personality() {
#if !defined(TARGET_BSD) && !defined(_ANDROID) && !defined(TARGET_OS_MAC) && !defined(TARGET_EMSCRIPTEN)
#if !defined(TARGET_BSD) && !defined(__ANDROID__) && !defined(TARGET_OS_MAC) && !defined(TARGET_EMSCRIPTEN)
DEBUG_LOG(BOOT, "Personality: %08X", personality(0xFFFFFFFF));
personality(~READ_IMPLIES_EXEC & personality(0xFFFFFFFF));
DEBUG_LOG(BOOT, "Updated personality: %08X", personality(0xFFFFFFFF));
@ -183,7 +183,7 @@ void linux_fix_personality() {
}
void linux_rpi2_init() {
#if !defined(TARGET_BSD) && !defined(_ANDROID) && !defined(TARGET_EMSCRIPTEN) && defined(TARGET_VIDEOCORE)
#if !defined(TARGET_BSD) && !defined(__ANDROID__) && !defined(TARGET_EMSCRIPTEN) && defined(TARGET_VIDEOCORE)
void* handle;
void (*rpi_bcm_init)(void);

View File

@ -1,6 +1,6 @@
#include "context.h"
#if defined(_ANDROID)
#if defined(__ANDROID__)
#include <asm/sigcontext.h>
#else
#if HOST_OS == OS_DARWIN

View File

@ -20,7 +20,7 @@
#define MAP_NOSYNC 0 //missing from linux :/ -- could be the cause of android slowness ?
#endif
#ifdef _ANDROID
#ifdef __ANDROID__
#include <linux/ashmem.h>
#ifndef ASHMEM_DEVICE
#define ASHMEM_DEVICE "/dev/ashmem"
@ -44,7 +44,7 @@ int ashmem_create_region(const char *name, size_t size) {
return fd;
}
#endif // #ifdef _ANDROID
#endif // #ifdef __ANDROID__
bool mem_region_lock(void *start, size_t len)
{
@ -109,7 +109,7 @@ bool mem_region_unmap_file(void *start, size_t len)
// Allocates memory via a fd on shmem/ahmem or even a file on disk
static int allocate_shared_filemem(unsigned size) {
int fd = -1;
#if defined(_ANDROID)
#if defined(__ANDROID__)
// Use Android's specific shmem stuff.
fd = ashmem_create_region(0, size);
#else

View File

@ -1,7 +1,7 @@
// Copyright 2015 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#ifdef _ANDROID
#ifdef __ANDROID__
#include <android/log.h>
@ -43,4 +43,4 @@ void ConsoleListener::Log(LogTypes::LOG_LEVELS level, const char* text)
__android_log_write(logLevel, LOG_TAG, text);
}
#endif // _ANDROID
#endif // __ANDROID__

View File

@ -1,7 +1,7 @@
// Copyright 2015 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#if !defined(_WIN32) && !defined(_ANDROID)
#if !defined(_WIN32) && !defined(__ANDROID__)
#include <cstdio>
#include <cstring>
@ -50,4 +50,4 @@ void ConsoleListener::Log(LogTypes::LOG_LEVELS level, const char* text)
}
fprintf(stderr, "%s%s%s", color_attr, text, reset_attr);
}
#endif // !_WIN32 && !_ANDROID
#endif // !_WIN32 && !__ANDROID__

View File

@ -11,7 +11,7 @@ constexpr u32 CODEPAGE_WINDOWS_1252 = 1252;
#include <locale.h>
#endif
#if !defined(_WIN32) && !defined(ANDROID) && !defined(__HAIKU__) && !defined(__OpenBSD__)
#if !defined(_WIN32) && !defined(__ANDROID__) && !defined(__HAIKU__) && !defined(__OpenBSD__)
static locale_t GetCLocale()
{
static locale_t c_locale = newlocale(LC_ALL_MASK, "C", nullptr);
@ -52,11 +52,11 @@ bool CharArrayFromFormatV(char* out, int outsize, const char* format, va_list ar
c_locale = _create_locale(LC_ALL, "C");
writtenCount = _vsnprintf_l(out, outsize, format, c_locale, args);
#else
#if !defined(ANDROID) && !defined(__HAIKU__) && !defined(__OpenBSD__)
#if !defined(__ANDROID__) && !defined(__HAIKU__) && !defined(__OpenBSD__)
locale_t previousLocale = uselocale(GetCLocale());
#endif
writtenCount = vsnprintf(out, outsize, format, args);
#if !defined(ANDROID) && !defined(__HAIKU__) && !defined(__OpenBSD__)
#if !defined(__ANDROID__) && !defined(__HAIKU__) && !defined(__OpenBSD__)
uselocale(previousLocale);
#endif
#endif
@ -84,7 +84,7 @@ std::string StringFromFormatV(const char* format, va_list args)
std::string temp = buf;
delete[] buf;
#else
#if !defined(ANDROID) && !defined(__HAIKU__) && !defined(__OpenBSD__)
#if !defined(__ANDROID__) && !defined(__HAIKU__) && !defined(__OpenBSD__)
locale_t previousLocale = uselocale(GetCLocale());
#endif
if (vasprintf(&buf, format, args) < 0)
@ -93,7 +93,7 @@ std::string StringFromFormatV(const char* format, va_list args)
buf = nullptr;
}
#if !defined(ANDROID) && !defined(__HAIKU__) && !defined(__OpenBSD__)
#if !defined(__ANDROID__) && !defined(__HAIKU__) && !defined(__OpenBSD__)
uselocale(previousLocale);
#endif

View File

@ -66,7 +66,7 @@ int64_t get_time_usec(void)
if (!QueryPerformanceCounter(&count))
return 0;
return count.QuadPart * 1000000 / freq.QuadPart;
#elif defined(_POSIX_MONOTONIC_CLOCK) || defined(__QNX__) || defined(ANDROID) || defined(__MACH__) || HOST_OS==OS_LINUX
#elif defined(_POSIX_MONOTONIC_CLOCK) || defined(__QNX__) || defined(__ANDROID__) || defined(__MACH__) || HOST_OS==OS_LINUX
struct timespec tv = {0};
if (clock_gettime(CLOCK_MONOTONIC, &tv) < 0)
return 0;
@ -654,7 +654,7 @@ void InitSettings()
settings.dispmanx.Keep_Aspect = true;
#endif
#if (HOST_OS != OS_LINUX || defined(_ANDROID) || defined(TARGET_PANDORA))
#if (HOST_OS != OS_LINUX || defined(__ANDROID__) || defined(TARGET_PANDORA))
settings.aica.BufferSize = 2048;
#else
settings.aica.BufferSize = 1024;
@ -751,7 +751,7 @@ void LoadSettings(bool game_specific)
settings.dispmanx.Keep_Aspect = cfgLoadBool(game_specific ? cfgGetGameId() : "dispmanx", "maintain_aspect", settings.dispmanx.Keep_Aspect);
#endif
#if (HOST_OS != OS_LINUX || defined(_ANDROID) || defined(TARGET_PANDORA))
#if (HOST_OS != OS_LINUX || defined(__ANDROID__) || defined(TARGET_PANDORA))
settings.aica.BufferSize=2048;
#else
settings.aica.BufferSize=1024;
@ -904,7 +904,7 @@ void SaveSettings()
GamepadDevice::SaveMaplePorts();
#ifdef _ANDROID
#ifdef __ANDROID__
void SaveAndroidSettings();
SaveAndroidSettings();
#endif

View File

@ -264,7 +264,7 @@ CSYM(arm_exit):
@@@@@@
@matrix mul
#ifndef _ANDROID
#ifndef __ANDROID__
.global CSYM(ftrv_asm)
HIDDEN(ftrv_asm)
CSYM(ftrv_asm):

View File

@ -57,7 +57,7 @@ struct DynaRBI: RuntimeBlockInfo
};
#ifdef _ANDROID
#ifdef __ANDROID__
#include <sys/syscall.h> // for cache flushing.
#endif
@ -71,7 +71,7 @@ void CacheFlush(void* code, void* pEnd)
#elif !defined(ARMCC)
void CacheFlush(void* code, void* pEnd)
{
#if !defined(_ANDROID) && HOST_OS!=OS_DARWIN
#if !defined(__ANDROID__) && HOST_OS!=OS_DARWIN
__clear_cache((void*)code, pEnd);
#else
void* start=code;

View File

@ -30,7 +30,7 @@ int fbdev = -1;
#define GL_MAJOR_VERSION 0x821B
#endif
#endif
#ifdef _ANDROID
#ifdef __ANDROID__
#include <android/native_window.h> // requires ndk r5 or newer
#endif
#include "deps/libpng/png.h"
@ -552,7 +552,7 @@ void dump_screenshot(u8 *buffer, u32 width, u32 height)
return false;
}
}
#ifdef _ANDROID
#ifdef __ANDROID__
EGLint format;
if (!eglGetConfigAttrib(gl.setup.display, config, EGL_NATIVE_VISUAL_ID, &format))
{
@ -1226,7 +1226,7 @@ void gl_load_osd_resources()
gl.OSD_SHADER.scale = glGetUniformLocation(gl.OSD_SHADER.program, "scale");
glUniform1i(glGetUniformLocation(gl.OSD_SHADER.program, "tex"), 0); //bind osd texture to slot 0
#ifdef _ANDROID
#ifdef __ANDROID__
int w, h;
if (osd_tex == 0)
osd_tex = loadPNG(get_readonly_data_path(DATA_PATH "buttons.png"), w, h);
@ -1382,7 +1382,7 @@ void UpdateFogTexture(u8 *fog_table, GLenum texture_slot, GLint fog_image_format
extern u16 kcode[4];
extern u8 rt[4],lt[4];
#if defined(_ANDROID)
#if defined(__ANDROID__)
extern float vjoy_pos[14][8];
#else
@ -1407,7 +1407,7 @@ float vjoy_pos[14][8]=
{96,320,64,64}, //ANALOG_POINT
{1}
};
#endif // !_ANDROID
#endif // !__ANDROID__
static List<Vertex> osd_vertices;
static bool osd_vertices_overrun;
@ -1486,7 +1486,7 @@ static void osd_gen_vertices()
void OSD_DRAW(bool clear_screen)
{
#ifdef _ANDROID
#ifdef __ANDROID__
if (osd_tex == 0)
gl_load_osd_resources();
if (osd_tex != 0)

View File

@ -3,7 +3,7 @@
#include <atomic>
#include "rend/rend.h"
#if (defined(GLES) && HOST_OS != OS_DARWIN && !defined(USE_SDL)) || defined(_ANDROID)
#if (defined(GLES) && HOST_OS != OS_DARWIN && !defined(USE_SDL)) || defined(__ANDROID__)
#define USE_EGL
#include <EGL/egl.h>
#include <EGL/eglext.h>

View File

@ -121,7 +121,7 @@ void gui_init()
ImGui::GetStyle().ItemSpacing = ImVec2(8, 8); // from 8,4
ImGui::GetStyle().ItemInnerSpacing = ImVec2(4, 6); // from 4,4
//ImGui::GetStyle().WindowRounding = 0;
#ifdef _ANDROID
#ifdef __ANDROID__
ImGui::GetStyle().GrabMinSize = 20.0f; // from 10
ImGui::GetStyle().ScrollbarSize = 24.0f; // from 16
ImGui::GetStyle().TouchExtraPadding = ImVec2(1, 1); // from 0,0
@ -183,7 +183,7 @@ void ImGui_Impl_NewFrame()
io.MousePos = ImVec2(-FLT_MAX, -FLT_MAX);
else
io.MousePos = ImVec2(real_x, real_y);
#ifdef _ANDROID
#ifdef __ANDROID__
// Put the "mouse" outside the screen one frame after a touch up
// This avoids buttons and the like to stay selected
if ((mo_buttons & 0xf) == 0xf)
@ -808,7 +808,7 @@ static void gui_display_settings()
{
ImGui::AlignTextToFramePadding();
ImGui::Text("%s", get_writable_config_path("").c_str());
#ifdef _ANDROID
#ifdef __ANDROID__
ImGui::SameLine(ImGui::GetContentRegionAvailWidth() - ImGui::CalcTextSize("Change").x - ImGui::GetStyle().FramePadding.x);
if (ImGui::Button("Change"))
gui_state = Onboarding;
@ -922,7 +922,7 @@ static void gui_display_settings()
controller_mapping_popup(gamepad);
#ifdef _ANDROID
#ifdef __ANDROID__
if (gamepad->is_virtual_gamepad())
{
if (ImGui::Button("Edit"))
@ -1240,7 +1240,7 @@ static void gui_display_settings()
}
if (ImGui::CollapsingHeader("Other", ImGuiTreeNodeFlags_DefaultOpen))
{
#ifndef _ANDROID
#ifndef __ANDROID__
ImGui::Checkbox("Serial Console", &settings.debug.SerialConsole);
ImGui::SameLine();
ShowHelpMarker("Dump the Dreamcast serial console to stdout");
@ -1291,7 +1291,7 @@ static void gui_display_settings()
#endif
);
ImGui::Text("Operating System: %s",
#ifdef _ANDROID
#ifdef __ANDROID__
"Android"
#elif HOST_OS == OS_LINUX
"Linux"
@ -1313,7 +1313,7 @@ static void gui_display_settings()
ImGui::Text("Renderer: %s", (const char *)glGetString(GL_RENDERER));
ImGui::Text("Version: %s", (const char *)glGetString(GL_VERSION));
}
#ifdef _ANDROID
#ifdef __ANDROID__
ImGui::Separator();
if (ImGui::Button("Send Logs")) {
void android_send_logs();
@ -1337,7 +1337,7 @@ static void gui_display_settings()
settings.dynarec.Enable = (bool)dynarec_enabled;
}
#ifdef _ANDROID
#ifdef __ANDROID__
static std::string current_library_path("/storage/emulated/0/Download");
#else
static std::string current_library_path("/home/raph/RetroPie/roms/dreamcast/");
@ -1556,7 +1556,7 @@ void gui_display_ui()
case VJoyEdit:
break;
case VJoyEditCommands:
#ifdef _ANDROID
#ifdef __ANDROID__
gui_display_vjoy_commands(screen_width, screen_height, scaling);
#endif
break;

View File

@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with reicast. If not, see <https://www.gnu.org/licenses/>.
*/
#ifdef _ANDROID
#ifdef __ANDROID__
#include "gui_android.h"
#include "gui.h"
@ -65,4 +65,4 @@ void gui_display_vjoy_commands(int screen_width, int screen_height, float scalin
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData(), false);
}
#endif // _ANDROID
#endif // __ANDROID__

View File

@ -55,7 +55,7 @@ void select_directory_popup(const char *prompt, float scaling, StringCallback ca
{
if (select_current_directory.empty())
{
#if defined(_ANDROID)
#if defined(__ANDROID__)
const char *home = getenv("REICAST_HOME");
if (home != NULL)
{
@ -117,7 +117,7 @@ void select_directory_popup(const char *prompt, float scaling, StringCallback ca
select_subfolders.push_back(std::string(1, (char)('A' + i)) + ":\\");
}
else
#elif _ANDROID
#elif __ANDROID__
if (select_current_directory == PSEUDO_ROOT)
{
error_message = "Storage Locations";
@ -179,7 +179,7 @@ void select_directory_popup(const char *prompt, float scaling, StringCallback ca
}
}
closedir(dir);
#if defined(_WIN32) || defined(_ANDROID)
#if defined(_WIN32) || defined(__ANDROID__)
if (!dotdot_seen)
select_subfolders.push_back("..");
#endif
@ -231,14 +231,14 @@ void select_directory_popup(const char *prompt, float scaling, StringCallback ca
child_path += native_separator;
#endif
}
#ifdef _ANDROID
#ifdef __ANDROID__
if (access(child_path.c_str(), R_OK) != 0)
child_path = PSEUDO_ROOT;
#endif
}
else
{
#if defined(_WIN32) || defined(_ANDROID)
#if defined(_WIN32) || defined(__ANDROID__)
if (path == PSEUDO_ROOT)
child_path = name;
else

View File

@ -11,7 +11,7 @@
#endif
#ifdef _ANDROID
#ifdef __ANDROID__
#include <sys/mman.h>
#undef PAGE_MASK
#define PAGE_MASK (PAGE_SIZE-1)

View File

@ -711,7 +711,7 @@ inline bool is_u16(u32 v) { return (u16)v==(u32)v; }
static inline void do_nada(...) { }
#ifdef _ANDROID
#ifdef __ANDROID__
#include <android/log.h>
#ifdef printf