/* sys_linux_init: * Top level system driver wakeup call. */ static int sys_linux_init (void) { /* Get OS type */ _unix_read_os_type(); if (os_type != OSTYPE_LINUX) return -1; /* FWIW */ /* This is the only bit that needs root privileges. First * we attempt to set our euid to 0, in case this is the * second time we've been called. */ __al_linux_have_ioperms = !seteuid (0); #ifdef ALLEGRO_LINUX_VGA __al_linux_have_ioperms &= !iopl (3); #endif __al_linux_have_ioperms &= !__al_linux_init_memory(); /* At this stage we can drop the root privileges. */ seteuid (getuid()); /* Initialise dynamic driver lists */ _unix_driver_lists_init(); if (_unix_gfx_driver_list) _driver_list_append_list(&_unix_gfx_driver_list, _linux_gfx_driver_list); /* Load dynamic modules */ _unix_load_modules(SYSTEM_LINUX); /* Initialise VGA helpers */ #ifdef ALLEGRO_LINUX_VGA if (__al_linux_have_ioperms) if (__al_linux_init_vga_helpers()) return -1; #endif /* Install emergency-exit signal handlers */ old_sig_abrt = signal(SIGABRT, signal_handler); old_sig_fpe = signal(SIGFPE, signal_handler); old_sig_ill = signal(SIGILL, signal_handler); old_sig_segv = signal(SIGSEGV, signal_handler); old_sig_term = signal(SIGTERM, signal_handler); old_sig_int = signal(SIGINT, signal_handler); #ifdef SIGQUIT old_sig_quit = signal(SIGQUIT, signal_handler); #endif /* Initialise async event processing */ if (__al_linux_bgman_init()) { /* shutdown everything. */ sys_linux_exit(); return -1; } /* Mark the beginning of time */ _al_unix_init_time(); return 0; }
/* _xwin_sysdrv_init: * Top level system driver wakeup call. */ static int _xwin_sysdrv_init(void) { char tmp[256]; _unix_read_os_type(); /* install emergency-exit signal handlers */ old_sig_abrt = signal(SIGABRT, _xwin_signal_handler); old_sig_fpe = signal(SIGFPE, _xwin_signal_handler); old_sig_ill = signal(SIGILL, _xwin_signal_handler); old_sig_segv = signal(SIGSEGV, _xwin_signal_handler); old_sig_term = signal(SIGTERM, _xwin_signal_handler); old_sig_int = signal(SIGINT, _xwin_signal_handler); #ifdef SIGQUIT old_sig_quit = signal(SIGQUIT, _xwin_signal_handler); #endif /* Initialise dynamic driver lists and load modules */ _unix_driver_lists_init(); if (_unix_gfx_driver_list) _driver_list_append_list(&_unix_gfx_driver_list, _xwin_gfx_driver_list); _unix_load_modules(SYSTEM_XWINDOWS); #ifdef ALLEGRO_HAVE_LIBPTHREAD _unix_bg_man = &_bg_man_pthreads; #else _unix_bg_man = &_bg_man_sigalrm; #endif /* Initialise bg_man */ if (_unix_bg_man->init()) { _xwin_sysdrv_exit(); return -1; } #ifdef ALLEGRO_MULTITHREADED if (_unix_bg_man->multi_threaded) { _xwin.mutex = _unix_create_mutex(); } #endif get_executable_name(tmp, sizeof(tmp)); set_window_title(get_filename(tmp)); if (get_config_int("system", "XInitThreads", 1)) XInitThreads(); /* Open the display, create a window, and background-process * events for it all. */ if (_xwin_open_display(0) || _xwin_create_window() || _unix_bg_man->register_func(_xwin_bg_handler)) { _xwin_sysdrv_exit(); return -1; } set_display_switch_mode(SWITCH_BACKGROUND); return 0; }