Beispiel #1
0
static int internal_init(int (*init_once)(void)) {
    uint32_t seed;
    int err;
    if ((err = get_random_seed(&seed)))
        return err;
    init_random_state(&random_state, seed);
#if defined(GENESIS_OS_WINDOWS)
    unsigned __int64 frequency;
    if (QueryPerformanceFrequency((LARGE_INTEGER*) &frequency)) {
        win32_time_resolution = 1.0 / (double) frequency;
    } else {
        return GenesisErrorSystemResources;
    }
    GetSystemInfo(&win32_system_info);
    page_size = win32_system_info.dwAllocationGranularity;
#else
    page_size = getpagesize();
#if defined(__MACH__)
    host_get_clock_service(mach_host_self(), SYSTEM_CLOCK, &cclock);
#endif
#endif

    if (init_once && (err = init_once())) {
        return err;
    }
    return 0;
}
Beispiel #2
0
static struct inode *f2fs_alloc_inode(struct super_block *sb)
{
	struct f2fs_inode_info *fi;

	fi = kmem_cache_alloc(f2fs_inode_cachep, GFP_F2FS_ZERO);
	if (!fi)
		return NULL;

	init_once((void *) fi);

	/* Initialize f2fs-specific inode info */
	fi->vfs_inode.i_version = 1;
	atomic_set(&fi->dirty_pages, 0);
	fi->i_current_depth = 1;
	fi->i_advise = 0;
	rwlock_init(&fi->ext_lock);
	init_rwsem(&fi->i_sem);
	INIT_RADIX_TREE(&fi->inmem_root, GFP_NOFS);
	INIT_LIST_HEAD(&fi->inmem_pages);
	mutex_init(&fi->inmem_lock);

	set_inode_flag(fi, FI_NEW_INODE);

	if (test_opt(F2FS_SB(sb), INLINE_XATTR))
		set_inode_flag(fi, FI_INLINE_XATTR);

	/* Will be used by directory only */
	fi->i_dir_level = F2FS_SB(sb)->dir_level;

#ifdef CONFIG_F2FS_FS_ENCRYPTION
	fi->i_crypt_info = NULL;
#endif
	return &fi->vfs_inode;
}
int
main (int argc, char **argv)
{
	int ret;
	SRunner *sr;
	Suite *s;

	/* init stuff */
	rb_profile_start ("rhythmdb-query-model test suite");

	rb_threads_init ();
	setlocale (LC_ALL, NULL);
	rb_debug_init (TRUE);
	rb_refstring_system_init ();
	rb_file_helpers_init (TRUE);

	/* setup tests */
	s = rhythmdb_query_model_suite ();
	sr = srunner_create (s);

	init_setup (sr, argc, argv);
	init_once (FALSE);

	srunner_run_all (sr, CK_NORMAL);
	ret = srunner_ntests_failed (sr);
	srunner_free (sr);


	rb_file_helpers_shutdown ();
	rb_refstring_system_shutdown ();

	rb_profile_end ("rhythmdb-query-model test suite");
	return ret;
}
int
main (int argc, char **argv)
{
	int ret;
	SRunner *sr;
	Suite *s;

	g_log_set_always_fatal (G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL);

	rb_threads_init ();
	rb_debug_init (TRUE);
	rb_refstring_system_init ();
	rb_file_helpers_init (TRUE);

	/* setup tests */
	s = rb_query_creator_suite ();
	sr = srunner_create (s);

	init_setup (sr, argc, argv);
	init_once (FALSE);
	
	srunner_run_all (sr, CK_NORMAL);
	ret = srunner_ntests_failed (sr);
	srunner_free (sr);

	rb_file_helpers_shutdown ();
	rb_refstring_system_shutdown ();

	return ret;
}
Beispiel #5
0
int ptc_init(RP rp)
{
	int i;
	TTY tp;
	char far *ptr = buf1;

	if (init_once(rp) == 2)
	  return RP_EGEN;
	
	constty = 0;
	
	for (i=0; i<NPTY; i++)
	{
		ptr = i<16 ? buf1 : buf2;
		tp = (TTY) (ptr + ( (i%16) * sizeof(struct tty) ));
		ttys[i]   = tp;
		tp->state = 0;
		tp->send  = tp->ucntl = 0;
		qinit(&tp->inq);
		qinit(&tp->outq);
		tp->dev = i;
		tp->pgrp = tp->pid = 0;
		tp->ccnt = tp->scnt = 0;
		tp->ocol = 0;
		rpqinit(&tp->crq);
		rpqinit(&tp->cwq);
		rpqinit(&tp->srq);
		rpqinit(&tp->swq);
		tp->crsel = tp->srsel = tp->cxsel = 0;
	}
#ifdef INTRO
	DosPutMessage(1,sizeof(pty_msg)-1,pty_msg);
#endif
	return RPDONE;
}
static struct inode *f2fs_alloc_inode(struct super_block *sb)
{
	struct f2fs_inode_info *fi;

	fi = kmem_cache_alloc(f2fs_inode_cachep, GFP_F2FS_ZERO);
	if (!fi)
		return NULL;

	init_once((void *) fi);

	/* Initialize f2fs-specific inode info */
	fi->vfs_inode.i_version = 1;
	atomic_set(&fi->dirty_dents, 0);
	fi->i_current_depth = 1;
	fi->i_advise = 0;
	rwlock_init(&fi->ext.ext_lock);
	init_rwsem(&fi->i_sem);

	set_inode_flag(fi, FI_NEW_INODE);

	if (test_opt(F2FS_SB(sb), INLINE_XATTR))
		set_inode_flag(fi, FI_INLINE_XATTR);

	/* Will be used by directory only */
	fi->i_dir_level = F2FS_SB(sb)->dir_level;

	return &fi->vfs_inode;
}
Beispiel #7
0
int
main (int argc, char **argv)
{
	int ret;
	SRunner *sr;
	Suite *s;

	rb_profile_start ("rb-file-helpers test suite");
	g_thread_init (NULL);
	rb_threads_init ();
	setlocale (LC_ALL, NULL);
	rb_debug_init (TRUE);
	rb_file_helpers_init (TRUE);

	/* setup tests */
	s = rb_file_helpers_suite ();
	sr = srunner_create (s);

	init_setup (sr, argc, argv);
	init_once (FALSE);

	srunner_run_all (sr, CK_NORMAL);
	ret = srunner_ntests_failed (sr);
	srunner_free (sr);

	rb_file_helpers_shutdown ();

	rb_profile_end ("rb-file-helpers test suite");
	return ret;
}
Beispiel #8
0
END_TEST

START_TEST (test_rb_check_dir_has_space)
{
	init_once (TRUE);
	fail_unless (rb_check_dir_has_space_uri ("file:///tmp", 1));
	fail_unless (rb_check_dir_has_space_uri ("file:///etc/passwd", 1));
	fail_unless (rb_check_dir_has_space_uri ("file:///tmp/NONEXISTANT_FILE", 1));
	fail_unless (rb_check_dir_has_space_uri ("file:///tmp/NONEXISTANT/THISDOESNTEXISTEITHER/NORDOESTHIS", G_MAXUINT64) == FALSE);
}
Beispiel #9
0
int io_init(RP rp)
{
	if (init_once(rp)==2) return RP_EGEN;
	io_gdt32 = 0;

#ifdef INTRO
	DosPutMessage(1,sizeof(io_msg)-1,io_msg);
#endif
	return RPDONE;
}
Beispiel #10
0
int map_init(RP rp)
{
	int i;
	if (init_once(rp) == 2) return RP_EGEN;
	for (i=0; i<NMAP; i++) {
		maps[i].sfnum = -1;
		maps[i].phys =
		maps[i].vmaddr = 0;
	}

#ifdef INTRO
	DosPutMessage(1,sizeof(map_msg)-1,map_msg);
#endif
	return RPDONE;
}
Beispiel #11
0
int con_init(RP rp)
{
	if (init_once(rp)==2) return RP_EGEN;

	conpos = 0;
	conlen = 0;
	conpid = 0;
	constty = 0;
	conrsel = 0;
	constate = 0;

#ifdef INTRO
	DosPutMessage(1,sizeof(con_msg)-1,con_msg);
#endif
	return RPDONE;
}
Beispiel #12
0
void
test_rhythmdb_setup (void)
{
	RhythmDBEntryTypeClass *etype_class;

	init_once (TRUE);

	db = rhythmdb_tree_new ("test");
	fail_unless (db != NULL, "failed to initialise DB");
	rhythmdb_start_action_thread (db);

	/* allow songs and ignored entries to be synced to for the tests */
	etype_class = RHYTHMDB_ENTRY_TYPE_GET_CLASS (RHYTHMDB_ENTRY_TYPE_SONG);
	etype_class->can_sync_metadata = (RhythmDBEntryTypeBooleanFunc)rb_true_function;
	etype_class->sync_metadata = (RhythmDBEntryTypeSyncFunc)rb_null_function;

	etype_class = RHYTHMDB_ENTRY_TYPE_GET_CLASS (RHYTHMDB_ENTRY_TYPE_IGNORE);
	etype_class->can_sync_metadata = (RhythmDBEntryTypeBooleanFunc)rb_true_function;
	etype_class->sync_metadata = (RhythmDBEntryTypeSyncFunc)rb_null_function;
}
static struct inode *f2fs_alloc_inode(struct super_block *sb)
{
	struct f2fs_inode_info *fi;

	fi = kmem_cache_alloc(f2fs_inode_cachep, GFP_NOFS | __GFP_ZERO);
	if (!fi)
		return NULL;

	init_once((void *) fi);

	/* Initialize f2fs-specific inode info */
	fi->vfs_inode.i_version = 1;
	atomic_set(&fi->dirty_dents, 0);
	fi->i_current_depth = 1;
	fi->i_advise = 0;
	rwlock_init(&fi->ext.ext_lock);

	set_inode_flag(fi, FI_NEW_INODE);

	return &fi->vfs_inode;
}
Beispiel #14
0
static int init(size_t *alloc_size, size_t pool_size)
{
	if (init_once(&g_init_flag) < 0) {
		fprintf(stderr, "init multi times!");
		return -1;
	}

	g_block_pages = (*alloc_size + PAGE_SIZE - 1) >> PAGE_SHIFT;
	g_pool_blocks = pool_size;
	if (g_block_pages <= 0 || g_pool_blocks <= 0)
		return -1;
	g_pool_pages = g_block_pages * g_pool_blocks + guard_pages(g_pool_blocks);

#ifndef MAP_ANONYMOUS
#	define MAP_ANONYMOUS MAP_ANON
#endif
	g_pool_addr = mmap(NULL, (g_pool_pages << PAGE_SHIFT), PROT_READ|PROT_WRITE,
			MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
	if (g_pool_addr == MAP_FAILED) {
		perror("mmap failed");
		return -2;
	}

	g_page_map = calloc(g_pool_pages, sizeof(struct page_info));
	if (g_page_map == NULL) {
		perror("calloc failed");
		munmap(g_pool_addr, (g_pool_pages << PAGE_SHIFT));
		return -3;
	}

	if (do_init_pool() < 0) {
		perror("do_init_pool failed");
		free(g_page_map);
		munmap(g_pool_addr, (g_pool_pages << PAGE_SHIFT));
		return -4;
	}

	*alloc_size = g_block_pages << PAGE_SHIFT;
	return 0;
}
Beispiel #15
0
/***********************************************************************
* plugin main ppu thread
***********************************************************************/
static void vsh_menu_thread(uint64_t arg)
{
    #ifdef DEBUG
    dbg_init();
    dbg_printf("programstart:\n");
    #endif

    uint16_t oldpad = 0, curpad = 0;
    CellPadData pdata;

    // wait for XMB, feedback
    sys_timer_sleep(13);

    //vshtask_notify("sprx running...");

    play_rco_sound("system_plugin", "snd_trophy");

    #ifdef HAVE_STARFIELD
    init_once(/* stars */);
    #endif

    // custom bg_color init
    a = GET_A(bg_color_menu[1]);
    r = GET_R(bg_color_menu[1]);
    g = GET_G(bg_color_menu[1]);
    b = GET_B(bg_color_menu[1]);

    while(1)
    {
        // if VSH Menu is running, we get pad data over our MyPadGetData()
        // else, we use the vsh pad_data struct
        if(menu_running)
            MyPadGetData(0, &pdata);
        else
            VSHPadGetData(&pdata);

        // if pad_data and we are in XMB(vshmain_EB757101() == 0)
        if((pdata.len > 0)
        && (vshmain_EB757101() == 0)
        )
        {
            curpad = (pdata.button[2] | (pdata.button[3] << 8));

            if((curpad & PAD_SELECT) && (curpad != oldpad))
            {
                switch(menu_running)
                {
                    // VSH Menu not running, start VSH Menu
                    case 0:
                      // main view and start on first entry 
                      view = line = 0;

                      //
                      pause_RSX_rendering();

                      // create VSH Menu heap memory from memory container 1("app")
                      create_heap(64);       // 64 MB

                      // initialize VSH Menu graphic (init drawing context, alloc buffers, blah, blah, blah...)
                      init_graphic();

                      // stop vsh pad
                      start_stop_vsh_pad(0);

                      // set menu_running
                      menu_running = 1;

                      break;

                    // VSH Menu is running, stop VSH Menu
                    case 1:
                      stop_VSH_Menu();

                      // restart vsh pad
                      start_stop_vsh_pad(1);

                      break;
                }

                oldpad = 0;
                sys_timer_usleep(300000);
            }


          // VSH Menu is running, draw menu / check pad
          if(menu_running)
          {
                #ifdef DEBUG
                dbg_printf("%p\n", pdata);
                #endif

                draw_frame(&pdata);

                flip_frame();

                if(curpad != oldpad)
                {

                    if(curpad & PAD_UP)
                    {
                        if(line <= 0){
                            line = 0;
                        }else{
                            line--;
                            play_rco_sound("system_plugin", "snd_cursor");
                        }
                    }

                    if(curpad & PAD_DOWN)
                    {
                        if(line >= max_menu[view]-1){
                            line = max_menu[view]-1;
                        }else{
                            line++;
                            play_rco_sound("system_plugin", "snd_cursor");
                        }
                    }

                    if(curpad & PAD_LEFT
                    || curpad & PAD_RIGHT) do_leftright_action(curpad);

                    if(curpad & PAD_CROSS) do_menu_action();

                }

                // ...

                sys_timer_usleep(30);

            } // end VSH Menu is running

            oldpad = curpad;
        }else{
            oldpad = 0;
        }
    }

    #ifdef DEBUG
    dbg_fini();
    #endif
    sys_ppu_thread_exit(0);
}