Example #1
0
/* The entry function. */
void
__start(int argc, char *argv[], char *env[], void (*cleanup)(void))
{

    handle_argv(argc, argv, env);

    if (&_DYNAMIC != NULL)
        atexit(cleanup);
    else {
        /*
         * Hack to resolve _end so we read the correct symbol.
         * Without this it will resolve to the copy in the library
         * that firsts requests it. We should fix the toolchain,
         * however this is is needed until this can take place.
         */
        *(volatile long *)&_end;

        _init_tls();
    }

#ifdef GCRT
    atexit(_mcleanup);
    monstartup(&eprol, &etext);
    __asm__("eprol:");
#endif

    handle_static_init(argc, argv, env);
    exit(main(argc, argv, env));
}
Example #2
0
/* The entry function, C part. */
void
_start1(fptr cleanup, int argc, char *argv[])
{
	char **env;
	const char *s;

	env = argv + argc + 1;
	environ = env;
	if (argc > 0 && argv[0] != NULL) {
		__progname = argv[0];
		for (s = __progname; *s != '\0'; s++)
			if (*s == '/')
				__progname = s + 1;
	}

	if (&_DYNAMIC != NULL)
		atexit(cleanup);
	else
		_init_tls();

#ifdef GCRT
	atexit(_mcleanup);
#endif
	atexit(_fini);
#ifdef GCRT
	monstartup(&eprol, &etext);
__asm__("eprol:");
#endif
	_init();
	exit( main(argc, argv, env) );
}
Example #3
0
/* The entry function. */
void
_start(char **ap, void (*cleanup)(void))
{
	int argc;
	char **argv;
	char **env;

	argc = *(long *)(void *)ap;
	argv = ap + 1;
	env = ap + 2 + argc;
	handle_argv(argc, argv, env);

	if (&_DYNAMIC != NULL)
		atexit(cleanup);
	else
		_init_tls();

#ifdef GCRT
	atexit(_mcleanup);
	monstartup(&eprol, &etext);
__asm__("eprol:");
#endif

	handle_static_init(argc, argv, env);
	exit(main(argc, argv, env));
}
Example #4
0
JNIEXPORT jint JNICALL jni_freerdp_new(JNIEnv *env, jclass cls)
{
	freerdp* instance;

#if defined(WITH_GPROF)
	monstartup("libfreerdp-android.so");
#endif

	// create instance
	instance = freerdp_new();
	instance->PreConnect = android_pre_connect;
	instance->PostConnect = android_post_connect;
	instance->Authenticate = android_authenticate;
	instance->VerifyCertificate = android_verify_certificate;
	instance->VerifyChangedCertificate = android_verify_changed_certificate;
	instance->ReceiveChannelData = android_receive_channel_data;
	

	// create context
	instance->ContextSize = sizeof(androidContext);
	instance->ContextNew = android_context_new;
	instance->ContextFree = android_context_free;
	freerdp_context_new(instance);

	return (jint) instance;
}
Example #5
0
start()
{
	struct kframe {
		int	kargc;
		char	*kargv[1];	/* size depends on kargc */
		char	kargstr[1];	/* size varies */
		char	kenvstr[1];	/* size varies */
	};
	register struct kframe *kfp;
	register char **targv;
	register char **argv;
	extern int errno;

	kfp = (struct kframe *) environ;
	for (argv = targv = &kfp->kargv[0]; *targv++; /* void */)
		/* void */ ;
	if (targv >= (char **)(*argv))
		--targv;
	environ = targv;
asm("eprol:");

#ifdef MCRT0
	monstartup(&eprol, &etext);
#endif
	errno = 0;
	if (argv[0])
		if ((__progname = strrchr(argv[0], '/')) == NULL)
			__progname = argv[0];
		else
			++__progname;
	exit(main(kfp->kargc, argv, environ));
}
Example #6
0
File: crt0.c Project: bingos/bitrig
void
___start(int argc, char **argv, char **envp, void *aux, void (*cleanup)(void))
{
	char *s;

	environ = envp;

	if ((__progname = argv[0]) != NULL) {   /* NULL ptr if argc = 0 */
		if ((__progname = _strrchr(__progname, '/')) == NULL)
			__progname = argv[0];
		else
			__progname++;
		for (s = __progname_storage; *__progname &&
		   s < &__progname_storage[sizeof __progname_storage - 1]; )
			*s++ = *__progname++;
		*s = '\0';
		__progname = __progname_storage;
	}

	if (cleanup)
		atexit(cleanup);

#ifdef MCRT0
	atexit(_mcleanup);
	monstartup((u_long)&_eprol, (u_long)&_etext);
#endif

#ifndef SCRT0
	__init();
#endif

	exit(main(argc, argv, environ));
}
Example #7
0
void
___start(int argc, char **argv, char **envp, void *ps_strings,
	const void *obj, void (*cleanup)(void))
{
	char *s;

 	environ = envp;

	if ((__progname = argv[0]) != NULL) {   /* NULL ptr if argc = 0 */
		if ((__progname = _strrchr(__progname, '/')) == NULL)
			__progname = argv[0];
		else
			__progname++;
		for (s = __progname_storage; *__progname &&
		    s < &__progname_storage[sizeof __progname_storage - 1]; )
			*s++ = *__progname++;
		*s = '\0';
		__progname = __progname_storage;
	}

#if 0
	atexit(cleanup);
#endif
#ifdef MCRT0
	atexit(_mcleanup);
	monstartup((u_long)&_eprol, (u_long)&_etext);
#endif	/* MCRT0 */

#ifndef SCRT0
        __init();
#endif

__asm("__callmain:");		/* Defined for the benefit of debuggers */
	exit(main(argc, argv, envp));
}
Example #8
0
JNIEXPORT jint JNICALL jni_freerdp_new(JNIEnv *env, jclass cls)
{
	freerdp* instance;

#if defined(WITH_GPROF)
	setenv("CPUPROFILE_FREQUENCY", "200", 1);
	monstartup("libfreerdp-android.so");
#endif

	// create instance
	if (!(instance = freerdp_new()))
		return (jint)NULL;
	instance->PreConnect = android_pre_connect;
	instance->PostConnect = android_post_connect;
	instance->PostDisconnect = android_post_disconnect;
	instance->Authenticate = android_authenticate;
	instance->VerifyCertificate = android_verify_certificate;
	instance->VerifyChangedCertificate = android_verify_changed_certificate;

	// create context
	instance->ContextSize = sizeof(androidContext);
	instance->ContextNew = android_context_new;
	instance->ContextFree = android_context_free;

	if (!freerdp_context_new(instance))
	{
		freerdp_free(instance);
		instance = NULL;
	}

	return (jint) instance;
}
Example #9
0
void initAndroid()
{
	porting::jnienv = NULL;
	JavaVM *jvm = app_global->activity->vm;
	JavaVMAttachArgs lJavaVMAttachArgs;
	lJavaVMAttachArgs.version = JNI_VERSION_1_6;
	lJavaVMAttachArgs.name = "MinetestNativeThread";
	lJavaVMAttachArgs.group = NULL;
#ifdef NDEBUG
	// This is a ugly hack as arm v7a non debuggable builds crash without this
	// printf ... if someone finds out why please fix it!
	infostream << "Attaching native thread. " << std::endl;
#endif
	if ( jvm->AttachCurrentThread(&porting::jnienv, &lJavaVMAttachArgs) == JNI_ERR) {
		errorstream << "Failed to attach native thread to jvm" << std::endl;
		exit(-1);
	}

	nativeActivity = findClass("net/minetest/minetest/MtNativeActivity");
	if (nativeActivity == 0) {
		errorstream <<
			"porting::initAndroid unable to find java native activity class" <<
			std::endl;
	}

#ifdef GPROF
	/* in the start-up code */
	__android_log_print(ANDROID_LOG_ERROR, PROJECT_NAME,
			"Initializing GPROF profiler");
	monstartup("libminetest.so");
#endif
}
Example #10
0
static void
IjkMediaPlayer_native_profileBegin(JNIEnv *env, jclass clazz, jstring libName)
{
    MPTRACE("IjkMediaPlayer_native_profileBegin");

    const char *c_lib_name = NULL;
    static int s_monstartup = 0;

    if (!libName)
        return;

    if (s_monstartup) {
        ALOGW("monstartup already called\b");
        return;
    }

    c_lib_name = (*env)->GetStringUTFChars(env, libName, NULL );
    JNI_CHECK_GOTO(c_lib_name, env, "java/lang/OutOfMemoryError", "mpjni: monstartup: libName.string oom", LABEL_RETURN);

    s_monstartup = 1;
    monstartup(c_lib_name);
    ALOGD("monstartup: %s\n", c_lib_name);

LABEL_RETURN:
    if (c_lib_name)
        (*env)->ReleaseStringUTFChars(env, libName, c_lib_name);
}
Example #11
0
File: crt0.c Project: Ga-vin/MINIX3
void
__start(int argc, char **argv, char **envp,
    void (*cleanup)(void),			/* from shared loader */
    const Obj_Entry *obj,			/* from shared loader */
    struct ps_strings *ps_strings)
{
	environ = envp;

	if ((__progname = argv[0]) != NULL) {	/* NULL ptr if argc = 0 */
		if ((__progname = _strrchr(__progname, '/')) == NULL)
			__progname = argv[0];
		else
			__progname++;
	}

	if (ps_strings != (struct ps_strings *)0)
		__ps_strings = ps_strings;

#ifdef DYNAMIC
	if (&_DYNAMIC != NULL)
		_rtld_setup(cleanup, obj);
#endif

#ifdef MCRT0
	atexit(_mcleanup);
	monstartup((u_long)&_eprol, (u_long)&_etext);
#endif

	atexit(_fini);
	_init();

	exit(main(argc, argv, environ));
}
Example #12
0
void testValues() {
    f = 2;
    
    monstartup(anylong(), anylong());

    //@ assert f == 2;
    //@ assert vacuous: \false;
}
Example #13
0
struct event_base *
rspamd_prepare_worker (struct rspamd_worker *worker, const char *name,
	void (*accept_handler)(int, short, void *), gboolean load_lua)
{
	struct event_base *ev_base;
	struct event *accept_events;
	GList *cur;
	struct rspamd_worker_listen_socket *ls;

#ifdef WITH_PROFILER
	extern void _start (void), etext (void);
	monstartup ((u_long) & _start, (u_long) & etext);
#endif

	gperf_profiler_init (worker->srv->cfg, name);

	worker->srv->pid = getpid ();
	worker->signal_events = g_hash_table_new_full (g_direct_hash, g_direct_equal,
			NULL, g_free);

	ev_base = event_init ();

	rspamd_worker_init_signals (worker, ev_base);
	rspamd_control_worker_add_default_handler (worker, ev_base);
#ifdef WITH_HIREDIS
	rspamd_redis_pool_config (worker->srv->cfg->redis_pool,
			worker->srv->cfg, ev_base);
#endif

	/* Accept all sockets */
	if (accept_handler) {
		cur = worker->cf->listen_socks;

		while (cur) {
			ls = cur->data;

			if (ls->fd != -1) {
				accept_events = g_slice_alloc0 (sizeof (struct event) * 2);
				event_set (&accept_events[0], ls->fd, EV_READ | EV_PERSIST,
						accept_handler, worker);
				event_base_set (ev_base, &accept_events[0]);
				event_add (&accept_events[0], NULL);
				worker->accept_events = g_list_prepend (worker->accept_events,
						accept_events);
			}

			cur = g_list_next (cur);
		}
	}

	if (load_lua) {
		struct rspamd_config *cfg = worker->srv->cfg;

		rspamd_lua_run_postloads (cfg->lua_state, cfg, ev_base, worker);
	}

	return ev_base;
}
Example #14
0
void profiler_start_profile(const char *tag) {
#ifdef PROFILER_ENABLED
	if (current_tag) {
		profiler_stop_profile();
	}
	current_tag = strdup(tag);
	monstartup(LIBRARY_NAME);
#endif
}
Example #15
0
start()
{
	struct kframe {
		int	kargc;
		char	*kargv[1];	/* size depends on kargc */
		char	kargstr[1];	/* size varies */
		char	kenvstr[1];	/* size varies */
	};
	/*
	 *	ALL REGISTER VARIABLES!!!
	 */
	register struct kframe *kfp;	/* r10 */
	register char **targv;
	register char **argv;
	extern int errno;
	extern void _mcleanup();

#ifdef lint
	kfp = 0;
	initcode = initcode = 0;
#else
	asm("lea 4(%ebp),%ebx");	/* catch it quick */
#endif
	for (argv = targv = &kfp->kargv[0]; *targv++; /* void */)
		/* void */ ;
	if (targv >= (char **)(*argv))
		--targv;
	environ = targv;
asm("eprol:");

#ifdef paranoid
	/*
	 * The standard I/O library assumes that file descriptors 0, 1, and 2
	 * are open. If one of these descriptors is closed prior to the start 
	 * of the process, I/O gets very confused. To avoid this problem, we
	 * insure that the first three file descriptors are open before calling
	 * main(). Normally this is undefined, as it adds two unnecessary
	 * system calls.
	 */
	do	{
		fd = open("/dev/null", 2);
	} while (fd >= 0 && fd < 3);
	close(fd);
#endif

#ifdef MCRT0
	atexit(_mcleanup);
	monstartup(&eprol, &etext);
#endif
	errno = 0;
	if (argv[0])
		if ((__progname = strrchr(argv[0], '/')) == NULL)
			__progname = argv[0];
		else
			++__progname;
	exit(main(kfp->kargc, argv, environ));
}
/**
 * This is the main entry point of a native application that is using
 * android_native_app_glue.  It runs in its own thread, with its own
 * event loop for receiving input events and doing other things.
 */
void android_main( android_app* state )
{
    app_dummy();

    g_engine.SetState( state );

    //Init helper functions
    ndk_helper::JNIHelper::GetInstance()->Init( state->activity, HELPER_CLASS_NAME );

    state->userData = &g_engine;
    state->onAppCmd = Engine::HandleCmd;
    state->onInputEvent = Engine::HandleInput;

#ifdef USE_NDK_PROFILER
    monstartup("libMoreTeapotsNativeActivity.so");
#endif

    // Prepare to monitor accelerometer
    g_engine.InitSensors();

    // loop waiting for stuff to do.
    while( 1 )
    {
        // Read all pending events.
        int id;
        int events;
        android_poll_source* source;

        // If not animating, we will block forever waiting for events.
        // If animating, we loop until all events are read, then continue
        // to draw the next frame of animation.
        while( (id = ALooper_pollAll( g_engine.IsReady() ? 0 : -1, NULL, &events, (void**) &source ))
                >= 0 )
        {
            // Process this event.
            if( source != NULL )
                source->process( state, source );

            g_engine.ProcessSensors( id );

            // Check if we are exiting.
            if( state->destroyRequested != 0 )
            {
                g_engine.TermDisplay();
                return;
            }
        }

        if( g_engine.IsReady() )
        {
            // Drawing is throttled to the screen update rate, so there
            // is no need to do timing here.
            g_engine.DrawFrame();
        }
    }
}
Example #17
0
volatile void
start(void)
{
	struct kframe {
		int	regarea[16];	/* space for %i and %o variables */
		int	kargc;		/* argument count */
		char	*kargv[1];	/* actual size depends on kargc */
	};
	register struct kframe *sp asm("%sp");
	register int argc;
	register char **argv, **envp;
	extern int errno;

asm(".globl start");
asm("start:");
	argc = sp->kargc;
	argv = &sp->kargv[0];
	environ = envp = &argv[argc + 1];
	sp = (struct kframe *)((int)sp - 16);
asm("eprol:");

#ifdef paranoid
	/*
	 * The standard I/O library assumes that file descriptors 0, 1, and 2
	 * are open. If one of these descriptors is closed prior to the start 
	 * of the process, I/O gets very confused. To avoid this problem, we
	 * insure that the first three file descriptors are open before calling
	 * main(). Normally this is undefined, as it adds two unnecessary
	 * system calls.
	 */
    {
	register int fd;
	do {
		fd = open("/dev/null", 2);
	} while (fd >= 0 && fd < 3);
	close(fd);
    }
#endif

#ifdef MCRT0
	monstartup(eprol, etext);
	atexit(_mcleanup);
	errno = 0;
#endif
	if (argv[0])
		if ((__progname = strrchr(argv[0], '/')) == NULL)
			__progname = argv[0];
		else
			++__progname;
	exit(main(argc, argv, envp));
}
Example #18
0
pid_t WriteOutWebpages(long int timestamp)
{
	struct IPDataStore *DataStore = IPDataStore;
	struct SummaryData **SummaryData;
	int NumGraphs = 0;
	pid_t graphpid;
	int Counter;
	/* Did we catch any packets since last time? */
	if (!DataStore) 
		return -2;
	// break off from the main line so we don't miss any packets while we graph
	graphpid = fork();
	switch (graphpid) {
		case 0: /* we're the child, graph. */
			{
#ifdef PROFILE
			// Got this incantation from a message board.  Don't forget to set
			// GMON_OUT_PREFIX in the shell
			extern void _start(void), etext(void);
			syslog(LOG_INFO, "Calling profiler startup...");
			monstartup((u_long) &_start, (u_long) &etext);
#endif
			signal(SIGHUP, SIG_IGN);
			nice(4); // reduce priority so I don't choke out other tasks
			// Count Number of IP's in datastore
			for (DataStore = IPDataStore, Counter = 0; DataStore; Counter++, DataStore = DataStore->Next);
			// +1 because we don't want to accidently allocate 0
			SummaryData = malloc(sizeof(struct SummaryData *)*Counter+1);
			DataStore = IPDataStore;
			while (DataStore) // Is not null
				{
				if (DataStore->FirstBlock->NumEntries > 0)
					{
					SummaryData[NumGraphs] = (struct SummaryData *) malloc(sizeof(struct SummaryData));
					GraphIp(DataStore, SummaryData[NumGraphs++], timestamp+LEAD*config.range);
					}
				DataStore = DataStore->Next;
				}
			MakeIndexPages(NumGraphs, SummaryData);
			_exit(0);
			}
		break;
		case -1:
			syslog(LOG_ERR, "Forking grapher child failed!");
			return -1;
		break;
		default: /* parent + successful fork, assume graph success */
			return(graphpid);
		break;
	}
}
Example #19
0
void
__start(int argc, char *argv[], char *envp[])
{

#ifdef PROFILE
	atexit(_mcleanup);
	monstartup((unsigned long)&_eprol, (unsigned long)&_etext);
#endif

	_init();
	atexit(_fini);

	exit(main(argc, argv, envp));
}
Example #20
0
void
_start(int argc, char **argv, char **envp,
    const Obj_Entry *obj,			/* from shared loader */
    void (*cleanup)(void),			/* from shared loader */
    struct ps_strings *ps_strings)		/* NetBSD extension */
{
	char *namep;

	/*
	 * Initialize the Small Data Area registers.
	 * _SDA_BASE is defined in the SVR4 ABI for PPC.
	 *
	 * Do the initialization in a PIC manner.
	 */
	__asm(
		"bcl 20,31,1f;"
		"1: mflr 11;"
		"addis 13,11,rtld_SDA_BASE_-1b@ha;"
		"addi 13,13,rtld_SDA_BASE_-1b@l;"
	    ::: "lr" );

	if ((namep = argv[0]) != NULL) {	/* NULL ptr if argc = 0 */
		if ((__progname = _strrchr(namep, '/')) == NULL)
			__progname = namep;
		else
			__progname++;
	}

	environ = envp;

	if (ps_strings != (struct ps_strings *)0)
		__ps_strings = ps_strings;

#ifdef DYNAMIC
	if (&rtld_DYNAMIC != NULL)
		_rtld_setup(cleanup, obj);
#endif

	_libc_init();

#ifdef MCRT0
	atexit(_mcleanup);
	monstartup((u_long)&_eprol, (u_long)&_etext);
#endif

	atexit(_fini);
	_init();

	exit(main(argc, argv, environ));
}
Example #21
0
void initAndroid()
{
    porting::jnienv = NULL;
    JavaVM *jvm = app_global->activity->vm;
    JavaVMAttachArgs lJavaVMAttachArgs;
    lJavaVMAttachArgs.version = JNI_VERSION_1_6;
    lJavaVMAttachArgs.name = PROJECT_NAME_C "NativeThread";
    lJavaVMAttachArgs.group = NULL;
#ifdef NDEBUG
    // This is a ugly hack as arm v7a non debuggable builds crash without this
    // printf ... if someone finds out why please fix it!
    infostream << "Attaching native thread. " << std::endl;
#endif
    if ( jvm->AttachCurrentThread(&porting::jnienv, &lJavaVMAttachArgs) == JNI_ERR) {
        errorstream << "Failed to attach native thread to jvm" << std::endl;
        exit(-1);
    }

    nativeActivity = findClass("org/freeminer/" PROJECT_NAME_C "/MtNativeActivity");
    if (nativeActivity == 0) {
        errorstream <<
                    "porting::initAndroid unable to find java native activity class" <<
                    std::endl;
    }

#ifdef GPROF
    /* in the start-up code */
    __android_log_print(ANDROID_LOG_ERROR, PROJECT_NAME_C,
                        "Initializing GPROF profiler");
    monstartup("libfreeminer.so");
#endif

    {
        // https://code.google.com/p/android/issues/detail?id=40753
        // http://stackoverflow.com/questions/10196361/how-to-check-the-device-running-api-level-using-c-code-via-ndk
        // http://developer.android.com/reference/android/os/Build.VERSION_CODES.html#JELLY_BEAN_MR2
        jclass versionClass = porting::jnienv->FindClass("android/os/Build$VERSION");
        if (versionClass) {
            jfieldID sdkIntFieldID = porting::jnienv->GetStaticFieldID(versionClass, "SDK_INT", "I");
            if (sdkIntFieldID) {
                android_version_sdk_int = porting::jnienv->GetStaticIntField(versionClass, sdkIntFieldID);
                infostream << "Android version = "<< android_version_sdk_int << std::endl;
            }
        }
    }

}
Example #22
0
File: crt0.c Project: Ga-vin/MINIX3
void
_start(int argc, char **argv, char **envp,
    const Obj_Entry *obj,			/* from shared loader */
    void (*cleanup)(void),			/* from shared loader */
    struct ps_strings *ps_strings)		/* NetBSD extension */
{
	char *namep;

	/*
	 * Initialize the Small Data Area registers.
	 * _SDA_BASE is defined in the SVR4 ABI for PPC.
	 * _SDA2_BASE is defined in the E[mbedded] ABI for PPC.
	 */
	__asm(  "lis %r13,_SDA_BASE_@ha;"
		"addi %r13,%r13,_SDA_BASE_@l;"
		"lis %r2,_SDA2_BASE_@ha;"
		"addi %r2,%r2,_SDA2_BASE_@l" );

	if ((namep = argv[0]) != NULL) {	/* NULL ptr if argc = 0 */
		if ((__progname = _strrchr(namep, '/')) == NULL)
			__progname = namep;
		else
			__progname++;
	}

	environ = envp;

	if (ps_strings != (struct ps_strings *)0)
		__ps_strings = ps_strings;

#ifdef DYNAMIC
	if (&_DYNAMIC != NULL)
		_rtld_setup(cleanup, obj);
#endif

#ifdef MCRT0
	atexit(_mcleanup);
	monstartup((u_long)&_eprol, (u_long)&_etext);
#endif

	atexit(_fini);
	_init();

	exit(main(argc, argv, environ));
}
Example #23
0
struct event_base *
rspamd_prepare_worker (struct rspamd_worker *worker, const char *name,
	void (*accept_handler)(int, short, void *))
{
	struct event_base *ev_base;
	struct event *accept_event;
	GList *cur;
	gint listen_socket;

#ifdef WITH_PROFILER
	extern void _start (void), etext (void);
	monstartup ((u_long) & _start, (u_long) & etext);
#endif

	gperf_profiler_init (worker->srv->cfg, name);

	worker->srv->pid = getpid ();
	worker->signal_events = g_hash_table_new_full (g_direct_hash, g_direct_equal,
			NULL, g_free);

	ev_base = event_init ();

	rspamd_worker_init_signals (worker, ev_base);
	rspamd_control_worker_add_default_handler (worker, ev_base);

	/* Accept all sockets */
	cur = worker->cf->listen_socks;
	while (cur) {
		listen_socket = GPOINTER_TO_INT (cur->data);
		if (listen_socket != -1) {
			accept_event = g_slice_alloc0 (sizeof (struct event));
			event_set (accept_event, listen_socket, EV_READ | EV_PERSIST,
				accept_handler, worker);
			event_base_set (ev_base, accept_event);
			event_add (accept_event, NULL);
			worker->accept_events = g_list_prepend (worker->accept_events,
					accept_event);
		}
		cur = g_list_next (cur);
	}

	return ev_base;
}
Example #24
0
/*
 * This is the highest address in Mesa
 */
extern void mesa_highpc(void);  /* silence compiler warning */
void mesa_highpc(void) { }

#if defined(__GNUC__) && defined(__linux__)

void monstartup( char *lowpc, char *highpc );
void _mcleanup( void );
void mesa_lowpc( void );
void mesa_highpc( void );

static int profile = 0;

extern void force_init_prof( void ); /* silence compiler warning */
void force_init_prof( void )
{
   FILE *fp;

   if (profile) return;

   profile = 1;

   monstartup( (char *)mesa_lowpc, (char *)mesa_highpc );

   fprintf(stderr, "Starting profiling, %x %x\n",
	   (unsigned int)mesa_lowpc,
	   (unsigned int)mesa_highpc);

   if ((fp = fopen( "mesa_lowpc", "w" )) != NULL) {
      fprintf( fp, "0x%08x ", (unsigned int)mesa_lowpc );
      fclose( fp );
   }
}
Example #25
0
jstring Java_com_googlecode_tesseract_android_TessBaseAPI_nativeGetUTF8Text(JNIEnv *env,
                                                                            jobject thiz) {

  native_data_t *nat = get_native_data(env, thiz);

#ifdef MY_ANDROID_NDK_PROFILER_ENABLED
  monstartup("tess.so");
#endif

  char *text = nat->api.GetUTF8Text();

#ifdef MY_ANDROID_NDK_PROFILER_ENABLED
  moncleanup();
#endif
  jstring result = env->NewStringUTF(text);

  free(text);

  return result;
}
Example #26
0
/* The entry function. */
void
__start(int argc, char *argv[], char *env[], void (*cleanup)(void))
{

	handle_argv(argc, argv, env);

	if (&_DYNAMIC != NULL)
		atexit(cleanup);
	else
		_init_tls();

#ifdef GCRT
	atexit(_mcleanup);
	monstartup(&eprol, &etext);
__asm__("eprol:");
#endif

	handle_static_init(argc, argv, env);
	exit(main(argc, argv, env));
}
Example #27
0
void __gmon_start__ (void)
{
#ifdef __UCLIBC_CTOR_DTOR__
    /* Protect from being called more than once.  Since crti.o is linked
       into every shared library, each of their init functions will call us.  */
    static int called;

    if (called)
	return;

    called = 1;
#endif

    /* Start keeping profiling records.  */
    monstartup ((u_long) &_start, (u_long) &etext);

    /* Call _mcleanup before exiting; it will write out gmon.out from the
       collected data.  */
    atexit (&_mcleanup);
}
Example #28
0
void
___start(char **sp,
         void (*cleanup)(void),			/* from shared loader */
         const Obj_Entry *obj,			/* from shared loader */
         struct ps_strings *ps_strings)
{
    long argc;
    char **argv, *namep;

    argc = *(long *)sp;
    argv = sp + 1;
    environ = sp + 2 + argc;		/* 2: argc + NULL ending argv */

    if ((namep = argv[0]) != NULL) {	/* NULL ptr if argc = 0 */
        if ((__progname = _strrchr(namep, '/')) == NULL)
            __progname = namep;
        else
            __progname++;
    }

    if (ps_strings != (struct ps_strings *)0 &&
            ps_strings != (struct ps_strings *)0xbabefacedeadbeef)
        __ps_strings = ps_strings;

#ifdef DYNAMIC
    if (&rtld_DYNAMIC != NULL)
        _rtld_setup(cleanup, obj);
#endif

    _libc_init();

#ifdef MCRT0
    atexit(_mcleanup);
    monstartup((u_long)&_eprol, (u_long)&_etext);
#endif

    atexit(_fini);
    _init();

    exit(main(argc, argv, environ));
}
Example #29
0
init_prof( void )
{
   FILE *fp;
   char *s = getenv("MESA_MON");

   if (s == NULL || atoi(s) == 0)
      return;

   profile = 1;

   monstartup( (char *)mesa_lowpc, (char *)mesa_highpc );

      fprintf(stderr, "Starting profiling, %x %x\n",
	      (unsigned int)mesa_lowpc,
	      (unsigned int)mesa_highpc);

   if ((fp = fopen( "mesa_lowpc", "w" )) != NULL) {
      fprintf( fp, "0x%08x ", (unsigned int)mesa_lowpc );
      fclose( fp );
   }
}
Example #30
0
// Add better error checking
int fork2()
	{
	pid_t pid;
	if (!(pid = fork()))
		{
		if (!fork())
			{
#ifdef PROFILE
				// Got this incantation from a message board.  Don't forget to set
				// GMON_OUT_PREFIX in the shell
				extern void _start(void), etext(void);
				syslog(LOG_INFO, "Calling profiler startup...");
				monstartup((u_long) &_start, (u_long) &etext);
#endif
			return(0);
			}		 
		_exit(0);
		}
	waitpid(pid, NULL, 0);
	return(1);
	}