<commit_before>
#include "rtapi.h"		/* RTAPI realtime OS API */
#include "rtapi_app.h"		/* RTAPI realtime module decls */

MODULE_AUTHOR("<NAME>");
MODULE_DESCRIPTION("RTAPI stubs for userland threadstyles");
MODULE_LICENSE("GPL2 or later");

int rtapi_app_main(void)
{
    rtapi_print_msg(RTAPI_MSG_INFO,"RTAPI startup\n");
    return 0;
}

void rtapi_app_exit(void)
{
    rtapi_print_msg(RTAPI_MSG_INFO,"RTAPI exit\n");
}<commit_msg>src/rtapi/rtapi_main.c changes<commit_after>/********************************************************************
* Description:  rtapi_main.c
*
*               This file, 'rtapi_main.c', implements the RTAPI
*               rtapi_app_main() and rtapi_app_exit() functions
*               for userspace thread systems.
*
*               It should not be used for kernel thread systems.
*
********************************************************************/

#include "config.h"

#include "rtapi_support.h"

#include <sys/ipc.h>		/* IPC_* */
#include <sys/shm.h>		/* shmget() */
#include <stdlib.h>		/* rand_r() */
#include <unistd.h>		/* getuid(), getgid(), sysconf(),
				   ssize_t, _SC_PAGESIZE */

#include "rtapi.h"		/* RTAPI realtime OS API */
#include "rtapi_app.h"		/* RTAPI realtime module decls */
#include "rtapi_common.h"       /* global_data_t */
#include "rtapi_kdetect.h"      /* environment autodetection */

// set in instance
extern int rtapi_instance;

#ifdef RTAPI
/* MODULE_AUTHOR("<NAME>"); */
/* MODULE_DESCRIPTION("RTAPI stubs for userland threadstyles"); */
/* MODULE_LICENSE("GPL2 or later"); */

/* // XXX FIXME: move to global sizing include */
/* static int hal_size = 262000; // HAL_SIZE */
/* RTAPI_MP_INT(hal_size, "size of the HAL data segment");
o */
#endif


static int check_compatible();

// int rtapi_app_main(void)
int real_rtapi_app_main(void)
{
    rtapi_print_msg(RTAPI_MSG_DBG,"RTAPI:%d %s %s init\n",
		    rtapi_instance,
		    rtapi_get_handle()->thread_flavor_name,
		    GIT_VERSION);

    return check_compatible();
}

//void rtapi_app_exit(void)
void real_rtapi_app_exit(void)
{
    rtapi_print_msg(RTAPI_MSG_DBG,"RTAPI:%d exit\n",
	      rtapi_instance);
}

EXPORT_SYMBOL(real_rtapi_app_main);
EXPORT_SYMBOL(real_rtapi_app_exit);

#if !defined(THREAD_FLAVOR_ID)
#error "THREAD_FLAVOR_ID is not defined!"
#endif

#if THREAD_FLAVOR_ID == RTAPI_XENOMAI_USER_ID
static int check_compatible()
{
    int retval = 0;

    if (!kernel_is_xenomai()) {
	rtapi_print_msg(RTAPI_MSG_ERR,
		  "RTAPI:%d started Xenomai RTAPI on a non-Xenomai kernel\n",
		  rtapi_instance);
	retval--;
    }

    if (kernel_is_rtai()) {
	rtapi_print_msg(RTAPI_MSG_ERR,
			"RTAPI:%d started Xenomai RTAPI on an RTAI kernel\n",
			rtapi_instance);
	//retval--;
    }
    if (kernel_is_rtpreempt()) {
	rtapi_print_msg(RTAPI_MSG_ERR,
			"RTAPI:%d started Xenomai RTAPI on an RT PREEMPT kernel\n",
			rtapi_instance);
	retval--;
    }
    return retval;
}

#elif THREAD_FLAVOR_ID ==  RTAPI_RT_PREEMPT_USER_ID

static int check_compatible()
{
   int retval = 0;

    if (!kernel_is_rtpreempt()) {
	rtapi_print_msg(RTAPI_MSG_ERR,
			"RTAPI:%d started RT_PREEMPT RTAPI on a non-RT PREEMPT kernel\n",
			rtapi_instance);
	// retval--;
    }

    if (kernel_is_rtai()) {
	rtapi_print_msg(RTAPI_MSG_ERR,
		  "RTAPI:%d started RT_PREEMPT RTAPI on an RTAI kernel\n",
		  rtapi_instance);
	// retval--;
    }
    if (kernel_is_xenomai()) {
	rtapi_print_msg(RTAPI_MSG_ERR,
		  "RTAPI:%d started RT_PREEMPT RTAPI on a Xenomai kernel\n",
		  rtapi_instance);
	// retval--;
    }
    return retval;
}

#elif THREAD_FLAVOR_ID == RTAPI_POSIX_ID

static int check_compatible()
{
    return 0; // no prerequisites
}

#else

#error "THREAD_FLAVOR_ID not set"
#endif
{'fraction_non_alphanumeric': 0.16170903190914007, 'fraction_numerical': 0.003244997295835587, 'mean_word_length': 3.938584779706275, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1513812', 'n_tokens_mistral': 1444, 'n_tokens_neox': 1376, 'n_words': 287}