Fixed compilation for libcurl

This commit is contained in:
pelya
2011-02-10 10:40:02 +00:00
parent 0f221c5477
commit fd86b04d47
7 changed files with 45 additions and 45 deletions

View File

@@ -1 +1 @@
fheroes2
ballfield

View File

@@ -0,0 +1 @@
../../../../sdl-1.3/src/video/android/SDL_fake_stdout.c

View File

@@ -229,6 +229,8 @@ JAVA_EXPORT_NAME(DemoRenderer_nativeInitJavaCallbacks) ( JNIEnv* env, jobject t
JavaShowScreenKeyboard = (*JavaEnv)->GetMethodID(JavaEnv, JavaRendererClass, "showScreenKeyboard", "()V");
ANDROID_InitOSKeymap();
SDL_ANDROID_initFakeStdout();
}
int SDL_ANDROID_SetApplicationPutToBackgroundCallback(

View File

@@ -51,6 +51,7 @@ extern void SDL_ANDROID_VideoContextRecreated();
extern void SDL_ANDROID_processAndroidTrackballDampening();
extern void SDL_ANDROID_processMoveMouseWithKeyboard();
extern int SDL_ANDROID_InsideVideoThread();
extern void SDL_ANDROID_initFakeStdout();
extern SDL_VideoDevice *ANDROID_CreateDevice_1_3(int devindex);
extern void SDL_ANDROID_ProcessDeferredEvents();
extern void SDL_ANDROID_WarpMouse(int x, int y);

View File

@@ -0,0 +1,40 @@
/*
Writing to stdout will crash your program on some particular Android tablets.
Although this is the device bug I've put a workaround here,
it is heavily dependent on NDK internals and is not portable in any way.
*/
#include <stdio.h>
#include <android/log.h>
extern FILE __SDL_fake_stdout[];
extern int __SDL_android_printf(const char * fmt, ...);
FILE __SDL_fake_stdout[3];
extern void SDL_ANDROID_initFakeStdout()
{
FILE * ff = NULL;
__SDL_fake_stdout[0] = * fopen("/dev/null", "r");
__SDL_fake_stdout[1] = * fopen("/dev/null", "w");
__SDL_fake_stdout[2] = * fopen("/dev/null", "w");
}
int __SDL_android_printf(const char * fmt, ...)
{
int return_value;
char buff[1024];
va_list ap;
va_start(ap, fmt);
/*
int characters = vfprintf(stdout, fmt, ap); // get buffer size
if(characters<0) return;
char* buff = new char[characters+1];
return_value = vsprintf(buff, fmt, ap);
*/
return_value = vsnprintf(buff, sizeof(buff), fmt, ap);
va_end(ap);
__android_log_print(ANDROID_LOG_INFO, "libSDL", buff);
//delete buff;
return return_value;
}

View File

@@ -1,46 +1,7 @@
/*
Writing to stdout will crash your program on some particular Android tablets.
Although this is the device bug I've put a workaround here,
it is heavily dependent on NDK internals and is not portable in any way.
*/
#ifndef _SDL_fake_stdout_h
#define _SDL_fake_stdout_h
#include <stdio.h>
#include <android/log.h>
#include <iostream>
extern "C" FILE __SDL_fake_stdout[];
FILE __SDL_fake_stdout[3];
extern "C" void SDL_ANDROID_initFakeStdout()
{
FILE * ff = NULL;
__SDL_fake_stdout[0] = * fopen("/dev/null", "r");
__SDL_fake_stdout[1] = * fopen("/dev/null", "w");
__SDL_fake_stdout[2] = * fopen("/dev/null", "w");
}
int __SDL_android_printf(const char * fmt, ...)
{
int return_value;
char buff[1024];
va_list ap;
va_start(ap, fmt);
/*
int characters = vfprintf(stdout, fmt, ap); // get buffer size
if(characters<0) return;
char* buff = new char[characters+1];
return_value = vsprintf(buff, fmt, ap);
*/
return_value = vsnprintf(buff, sizeof(buff), fmt, ap);
va_end(ap);
__android_log_print(ANDROID_LOG_INFO, "libSDL", buff);
//delete buff;
return return_value;
}
/* Outputting anything to cout/cerr WILL CRASH YOUR PROGRAM on specific devices -
x5a/x6d Android 2.1 tablet, and some other tablets,
however the same code runs on my HTC Evo without problem.
@@ -119,4 +80,3 @@ ostream __SDL_fake_cerr(new _android_debugbuf());
ostream __SDL_fake_clog(new _android_debugbuf());
}
#endif

View File

@@ -24,8 +24,6 @@
#define JAVA_EXPORT_NAME1(name,package) JAVA_EXPORT_NAME2(name,package)
#define JAVA_EXPORT_NAME(name) JAVA_EXPORT_NAME1(name,SDL_JAVA_PACKAGE_PATH)
extern C_LINKAGE void SDL_ANDROID_initFakeStdout(void);
extern C_LINKAGE void
JAVA_EXPORT_NAME(DemoRenderer_nativeInit) ( JNIEnv* env, jobject thiz, jstring jcurdir, jstring cmdline )
{
@@ -88,8 +86,6 @@ JAVA_EXPORT_NAME(DemoRenderer_nativeInit) ( JNIEnv* env, jobject thiz, jstring
for( i = 0; i < argc; i++ )
__android_log_print(ANDROID_LOG_INFO, "libSDL", "param %d = \"%s\"", i, argv[i]);
SDL_ANDROID_initFakeStdout();
main( argc, argv );
};