Example #1
0
static error_t
pc_mouse_start (void *handle)
{
  error_t err;
  char device_name[9];
  int devnum = majordev << 3 | minordev;
  device_t device_master;

  sprintf (device_name, "mouse%d", devnum);
  err = get_privileged_ports (0, &device_master);
  if (err)
    return err;
  
  err = device_open (device_master, D_READ, device_name, &mousedev);
  mach_port_deallocate (mach_task_self (), device_master);
  if (err)
    return ENODEV;

  err = driver_add_input (&pc_mouse_ops, NULL);
  if (err)
    {
      device_close (mousedev);
      mach_port_deallocate (mach_task_self (), mousedev);

      return err;
    }

  cthread_detach (cthread_fork (input_loop, NULL));
  
  if (repeater_node)
    setrepeater (repeater_node);
  
  return 0;
}
Example #2
0
bool options_parse_driver(options_state_t *s)
{
	const char *option = s->argv[s->i];
	if (option[0] != '-' || option[1] == '\0') {
		/* argument is not an option but an input filename */
		compilation_unit_type_t type = forced_unittype;
		if (type == COMPILATION_UNIT_AUTODETECT && streq(option, "-")) {
			/* - implicitly means C source file */
			type = COMPILATION_UNIT_C;
		}
		driver_add_input(option, type);
		s->had_inputs = true;
		return true;
	}
	++option;

	const char *arg;
	if ((arg = prefix_arg("o", s)) != NULL) {
		outname = arg;
	} else if ((arg = prefix_arg("x", s)) != NULL) {
		forced_unittype = get_unit_type_from_string(arg);
		if (forced_unittype == COMPILATION_UNIT_UNKNOWN) {
			errorf(NULL, "unknown language '%s'", arg);
			s->argument_errors = true;
			return false;
		}
	} else if (simple_arg("pipe", s)) {
		/* here for gcc compatibility */
	} else if ((arg = equals_arg("std", s)) != NULL
	        || (arg = equals_arg("-std", s)) != NULL) {
		set_language_standard(arg);
	} else if (simple_arg("ansi", s)) {
		standard = STANDARD_ANSI;
	} else if (simple_arg("-gcc", s)) {
		features_on  |=  _GNUC;
		features_off &= ~_GNUC;
	} else if (simple_arg("-no-gcc", s)) {
		features_on  &= ~_GNUC;
		features_off |=  _GNUC;
	} else if (simple_arg("-ms", s)) {
		features_on  |=  _MS;
		features_off &= ~_MS;
	} else if (simple_arg("-no-ms", s)) {
		features_on  &= ~_MS;
		features_off |=  _MS;
	} else if (simple_arg("-print-implicit-cast", s)) {
		print_implicit_casts = true;
	} else if (simple_arg("-print-parenthesis", s)) {
		print_parenthesis = true;
	} else if ((arg = spaced_arg("-jna-limit", s)) != NULL) {
		jna_limit_output(arg);
	} else if ((arg = spaced_arg("-jna-libname", s)) != NULL) {
		jna_set_libname(arg);
	} else if (simple_arg("v", s)) {
		driver_verbose = true;
	} else if (simple_arg("-time", s)) {
		do_timing    = true;
		print_timing = true;
	} else if (simple_arg("-statev", s)) {
		do_timing      = true;
		produce_statev = true;
	} else if ((arg = equals_arg("-filtev", s)) != NULL) {
		filtev = arg;
	} else if (simple_arg("version", s) || simple_arg("-version", s)) {
		s->action = action_version;
	} else if (simple_arg("dumpversion", s)) {
		s->action = action_version_short;
	} else if (simple_arg("dumpmachine", s)) {
		s->action = action_dumpmachine;
	} else if (option[0] == 'd') {
		/* scan debug flags */
		for (const char *flag = &option[1]; *flag != '\0'; ++flag) {
			if (*flag == 'M')
				dump_defines = true;
		}
	} else {
		return false;
	}
	return true;
}