Пример #1
0
CAMLprim value caml_weak_blit (value ars, value ofs,
                               value ard, value ofd, value len)
{
  mlsize_t offset_s = Long_val (ofs) + 1;
  mlsize_t offset_d = Long_val (ofd) + 1;
  mlsize_t length = Long_val (len);
  long i;
                                                   Assert (Is_in_heap (ars));
                                                   Assert (Is_in_heap (ard));
  if (offset_s < 1 || offset_s + length > Wosize_val (ars)){
    caml_invalid_argument ("Weak.blit");
  }
  if (offset_d < 1 || offset_d + length > Wosize_val (ard)){
    caml_invalid_argument ("Weak.blit");
  }
  if (caml_gc_phase == Phase_mark && caml_gc_subphase == Subphase_weak1){
    for (i = 0; i < length; i++){
      value v = Field (ars, offset_s + i);
      if (v != caml_weak_none && Is_block (v) && Is_in_heap (v)
          && Is_white_val (v)){
        Field (ars, offset_s + i) = caml_weak_none;
      }
    }
  }
  if (offset_d < offset_s){
    for (i = 0; i < length; i++){
      do_set (ard, offset_d + i, Field (ars, offset_s + i));
    }
  }else{
    for (i = length - 1; i >= 0; i--){
      do_set (ard, offset_d + i,  Field (ars, offset_s + i));
    }
  }
  return Val_unit;
}
Пример #2
0
int select_checker(struct config *conf, struct path *pp)
{
	char *origin, *checker_name;
	struct checker * c = &pp->checker;

	do_set(checker_name, conf->overrides, checker_name, "(setting: multipath.conf overrides section)");
	do_set(checker_name, pp->hwe, checker_name, "(setting: array configuration)");
	do_set(checker_name, conf, checker_name, "(setting: multipath.conf defaults/devices section)");
	do_default(checker_name, DEFAULT_CHECKER);
out:
	checker_get(conf->multipath_dir, c, checker_name);
	condlog(3, "%s: path_checker = %s %s", pp->dev, c->name, origin);
	if (conf->checker_timeout) {
		c->timeout = conf->checker_timeout;
		condlog(3, "%s: checker timeout = %u s (setting: multipath.conf defaults/devices section)",
				pp->dev, c->timeout);
	}
	else if (sysfs_get_timeout(pp, &c->timeout) > 0)
		condlog(3, "%s: checker timeout = %u ms (setting: kernel sysfs)",
				pp->dev, c->timeout);
	else {
		c->timeout = DEF_TIMEOUT;
		condlog(3, "%s: checker timeout = %u ms (setting: multipath internal)",
				pp->dev, c->timeout);
	}
	return 0;
}
Пример #3
0
 LUABIND_API void set_package_preload(
     lua_State * L, char const* modulename, object const& loader)
 {
     loader.push(L);
     lua_pushcclosure(L, &proxy_loader, 1);
     object const proxy_ldr(from_stack(L, -1));
     lua_pop(L, 1); // pop do_load.
     lua_pushcfunction(L, &do_set_package_preload);
     // Must use object for correct popping in case of errors:
     object do_set(from_stack(L, -1));
     lua_pop(L, 1);
     do_set(modulename, proxy_ldr);
 }
Пример #4
0
int main (void) {
    int id_status[SIZE], i;
    initialize(id_status);
    do_set(id_status, 23432);
    do_set(id_status, 23436);
    do_set(id_status, 23434);
    for(i=23430; i<23437; i++) {
        if (is_set(id_status, i))
            printf("%d is set\n", i);
        else
            printf("%d is not set\n", i);
    }
    return 0;
}
Пример #5
0
int
select_minio_rq (struct config *conf, struct multipath * mp)
{
	char *origin;

	do_set(minio_rq, mp->mpe, mp->minio, "(setting: multipath.conf multipaths section)");
	do_set(minio_rq, conf->overrides, mp->minio, "(setting: multipath.conf overrides section)");
	do_set(minio_rq, mp->hwe, mp->minio, "(setting: array configuration)");
	do_set(minio_rq, conf, mp->minio, "(setting: multipath.conf defaults/devices section)");
	do_default(mp->minio, DEFAULT_MINIO_RQ);
out:
	condlog(3, "%s: minio = %i %s", mp->alias, mp->minio, origin);
	return 0;
}
Пример #6
0
rstat op_cmp_delete( dict *d, void *key, void *old_val ) {
    location *locator = NULL;
    set_spec sp = { 0, 1, old_val, NULL };
    rstat err = do_set( d, &locator, key, NULL, &sp );
    if ( locator != NULL ) free_location( d, locator );
    return err;
}
Пример #7
0
rstat op_update( dict *d, void *key, void *val ) {
    location *locator = NULL;
    set_spec sp = { 0, 1, NULL, NULL };
    rstat err = do_set( d, &locator, key, val, &sp );
    if ( locator != NULL ) free_location( d, locator );
    return err;
}
Пример #8
0
void do_set(const std::string& symbol, const std::string& expr)
{
    int lookup = lc3_sym_lookup(state, symbol);
    if (lookup == -1)
        return;
    do_set((unsigned short)lookup, expr);
}
Пример #9
0
void do_set(unsigned char reg, const std::string& expr)
{
    int value_calc;
    if (lc3_calculate(state, expr, value_calc))
        return;
    do_set(reg, (short)value_calc);
}
Пример #10
0
int __do_set(const char *file, const struct stat *stat,
             int flag, struct FTW *ftw)
{
	if (flag & FTW_DNR) {
		/* Item is a directory which can't be read. */
		fprintf(stderr, "%s: %s: %s\n",
			progname, file, strerror(errno));
		return 0;
	}

	/* Process the target of a symbolic link, and traverse the link,
	   only if doing a logical walk, or if the symbolic link was
	   specified on the command line. Always skip symbolic links if
	   doing a physical walk. */

	if (S_ISLNK(stat->st_mode) &&
	    (opt_walk_physical || (ftw->level > 0 && !opt_walk_logical)))
		return 0;

	if (do_set(file, stat, __seq))
		__errors++;

	/* We also get here in non-recursive mode. In that case,
	   return something != 0 to abort nftw. */

	if (!opt_recursive)
		return 1;

	return 0;
}
Пример #11
0
void do_set(unsigned short address, const std::string& expr)
{
    int value_calc;
    if (lc3_calculate(state, expr, value_calc))
        return;
    do_set(address, (short)value_calc);
}
Пример #12
0
rstat op_cmp_update( dict *d, void *key, void *old_val, void *new_val ) {
    if ( old_val == NULL ) return error( 1, 0, DICT_API_MISUSE, "NULL can not be used as the 'old value' in compare and swap" );
    location *locator = NULL;
    set_spec sp = { 0, 1, old_val, NULL };
    rstat err = do_set( d, &locator, key, new_val, &sp );
    if ( locator != NULL ) free_location( d, locator );
    return err;
}
Пример #13
0
mpdm_t do_test_exec(mpdm_t x, mpdm_t a)
{
    static mpdm_t v = NULL;

    do_set(&v, mpdm_exec(x, a, NULL));

    return (v);
}
Пример #14
0
rstat op_trigger( dict *d, void *key, dict_trigger *t, void *targ, void *val ) {
    location *locator = NULL;
    set_spec sp = { 1, 0, NULL, NULL, t, targ };
    rstat err = do_set( d, &locator, key, val, &sp );
    if ( locator != NULL ) {
        free_location( d, locator );
    }
    return err;
}
Пример #15
0
rstat op_insert( dict *d, void *key, void *val ) {
    location *locator = NULL;
    set_spec sp = { 1, 0, NULL, NULL };
    rstat err = do_set( d, &locator, key, val, &sp );
    if ( locator != NULL ) {
        free_location( d, locator );
    }
    return err;
}
Пример #16
0
	void set(DWORD This, DWORD OutClass, char* name)
	{
		int var_type = GetVarType(This, 0);

		if ((CC_TYPE__begin < var_type) && (var_type < CC_TYPE__end))
		{
			do_set(OutClass, TypeName[var_type], (LPCSTR)&GetGUIVar_Value(This, 1), global, [&](){ PUT_VAR(This, 2); } );
		}
	}
Пример #17
0
mpdm_t do_test_mpsl_file(char *file, mpdm_t inc)
{
    static mpdm_t v = NULL;

    do_set(&v, mpsl_compile_file(MPDM_MBS(file), inc));

    printf("Compile file: ");
    do_test(file, v != NULL);
    return (v);
}
Пример #18
0
static int do_pqr_pair(const struct dist_g_ba *dist,
                       const struct shape *shape1,
                       const struct shape *shape2,
                       struct vec2 *Qsum,
                       struct mtx2 *Cinv_sum)
{

    double P=0, Q1=0,Q2=0, R11=0,R12=0,R22=0;
    struct vec2 QbyP_1={0}, QbyP_2={0};
    struct mtx2 Cinv_1={0}, Cinv_2={0};

    dist_g_ba_pqr(dist,
                  shape1,
                  &P,
                  &Q1,
                  &Q2,
                  &R11,
                  &R12,
                  &R22);

    if (!do_set(&QbyP_1, &Cinv_1, P, Q1, Q2, R11, R12, R22)) {
        return 0;
    }
    dist_g_ba_pqr(dist,
                  shape2,
                  &P,
                  &Q1,
                  &Q2,
                  &R11,
                  &R12,
                  &R22);

    if (!do_set(&QbyP_2, &Cinv_2, P, Q1, Q2, R11, R12, R22)) {
        return 0;
    }

    vec2_sumi(Qsum, &QbyP_1);
    mtx2_sumi(Cinv_sum, &Cinv_1);
    vec2_sumi(Qsum, &QbyP_2);
    mtx2_sumi(Cinv_sum, &Cinv_2);

    return 1;
}
Пример #19
0
mpdm_t _do_test_mpsl(char *code, int line)
{
    static mpdm_t v = NULL;

    do_set(&v, mpsl_compile(MPDM_MBS(code), NULL));

    printf("Compile: ");
    _do_test(code, v != NULL, line);
    return (v);
}
Пример #20
0
int dispatch_cmd(otts_synth_plugin_t *synth, char *cmd_line)
{
	char *cmd = NULL;
	size_t cmd_len;
	char *msg = NULL;

	cmd_len = strcspn(cmd_line, " \t\n\r\f");
	cmd = g_strndup(cmd_line, cmd_len);
	pthread_mutex_lock(&module_stdout_mutex);

	if (!strcasecmp("audio", cmd)) {
		msg = do_audio(synth);
	} else if (!strcasecmp("set", cmd)) {
		msg = do_set(synth);
	} else if (!strcasecmp("speak", cmd)) {
		msg = do_speak(synth);
	} else if (!strcasecmp("key", cmd)) {
		msg = do_key(synth);
	} else if (!strcasecmp("sound_icon", cmd)) {
		msg = do_sound_icon(synth);
	} else if (!strcasecmp("char", cmd)) {
		msg = do_char(synth);
	} else if (!strcasecmp("pause", cmd)) {
		do_pause(synth);
	} else if (!strcasecmp("stop", cmd)) {
		do_stop(synth);
	} else if (!strcasecmp("list_voices", cmd)) {
		msg = do_list_voices(synth);
	} else if (!strcasecmp("loglevel", cmd)) {
		msg = do_loglevel(synth);
	} else if (!strcasecmp("debug", cmd)) {
		msg = do_debug(synth, cmd_line);
	} else if (!strcasecmp("quit", cmd)) {
		do_quit(synth);
	} else {
/*should we log?*/
		printf("300 ERR UNKNOWN COMMAND\n");
		fflush(stdout);
	}

	if (msg != NULL) {
		if (0 > printf("%s\n", msg)) {
			log_msg(OTTS_LOG_CRIT, "Broken pipe, exiting...\n");
			synth->close(2);
		}
		fflush(stdout);
		g_free(msg);
	}

	pthread_mutex_unlock(&module_stdout_mutex);
	g_free(cmd);

	return (0);
}
Пример #21
0
void plc_hmi_set_dout( uint32_t i, bool val )
{
    void (*do_set)(uint32_t, uint16_t);

    if (PLC_DO_NUM<=i)
    {
        return;
    }
    do_set = (val)?gpio_set:gpio_clear;

    do_set(hmi[i].port, hmi[i].pin);
}
Пример #22
0
    static ERL_NIF_TERM robin_q_new(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) {
        robin_q_handle* handle = (robin_q_handle*)enif_alloc_resource(robin_q_RESOURCE,
                sizeof(robin_q_handle));

        handle->env         = enif_alloc_env();
        handle->lock        = enif_rwlock_create("robin_q");

        do_set(handle, argv[0]);

        ERL_NIF_TERM result = enif_make_resource(env, handle);
        enif_release_resource(handle);
        return enif_make_tuple2(env, enif_make_atom(env, "ok"), result);
    }
Пример #23
0
static int
want_user_friendly_names(struct config *conf, struct multipath * mp)
{

	char *origin;
	int user_friendly_names;

	do_set(user_friendly_names, mp->mpe, user_friendly_names,
	       "(setting: multipath.conf multipaths section)");
	do_set(user_friendly_names, conf->overrides, user_friendly_names,
	       "(setting: multipath.conf overrides section)");
	do_set(user_friendly_names, mp->hwe, user_friendly_names,
	       "(setting: array configuration)");
	do_set(user_friendly_names, conf, user_friendly_names,
	       "(setting: multipath.conf defaults/devices section)");
	do_default(user_friendly_names, DEFAULT_USER_FRIENDLY_NAMES);
out:
	condlog(3, "%s: user_friendly_names = %s %s", mp->wwid,
		(user_friendly_names == USER_FRIENDLY_NAMES_ON)? "yes" : "no",
		origin);
	return (user_friendly_names == USER_FRIENDLY_NAMES_ON);
}
Пример #24
0
    static ERL_NIF_TERM robin_q_set(ErlNifEnv *env, int argc, const ERL_NIF_TERM argv[]) {
        robin_q_handle *handle = NULL;
        if (enif_get_resource(env, argv[0], robin_q_RESOURCE, (void**)&handle) == 0) {
            return enif_make_badarg(env);
        }

        enif_rwlock_rwlock(handle->lock);
        enif_clear_env(handle->env);
        do_set(handle, argv[1]);
        enif_rwlock_rwunlock(handle->lock);

        return enif_make_atom(env, "ok");
    }
Пример #25
0
void iq_opt_insert_doread(iq_t iq, seqno_t i, iq_item_t msg) {
    item_t *item ;
    seqno_t next ;
    assert(iq_opt_insert_check(iq, i)) ;
    assert (i >= iq->lo) ;
    next = i + 1 ;
    iq->read = next ;
    iq->hi = next ;
    if (i >= maxi(iq)) {
	overflow(iq, i) ;
    }
    item = get_unsafe(iq, i) ;
    do_set(item, msg) ;
}
Пример #26
0
CAMLprim value caml_weak_set (value ar, value n, value el)
{
  mlsize_t offset = Long_val (n) + 1;
                                                   Assert (Is_in_heap (ar));
  if (offset < 1 || offset >= Wosize_val (ar)){
    caml_invalid_argument ("Weak.set");
  }
  if (el != None_val && Is_block (el)){
                                              Assert (Wosize_val (el) == 1);
    do_set (ar, offset, Field (el, 0));
  }else{
    Field (ar, offset) = caml_weak_none;
  }
  return Val_unit;
}
Пример #27
0
int do_iplink(int argc, char **argv)
{
	if (argc > 0) {
		if (matches(*argv, "set") == 0)
			return do_set(argc-1, argv+1);
		if (matches(*argv, "show") == 0 ||
		    matches(*argv, "lst") == 0 ||
		    matches(*argv, "list") == 0)
			return ipaddr_list_link(argc-1, argv+1);
	} else
		return ipaddr_list_link(0, NULL);

	bb_error_msg("Command \"%s\" is unknown.", *argv);
	exit(-1);
}
Пример #28
0
int main(int argc, char **argv)
{
	check_for_root_maybe_die();

	if (argc <= 1)
		usage();
	argc--;	argv++;
	if (!strncmp("help", argv[0], strlen("help")))
		usage();
	else if (!strncmp("version", argv[0], strlen("version")))
		version();
	else if (!strncmp("preload", argv[0], strlen("preload")))
		do_preload(--argc, ++argv);
	else if (!strncmp("add", argv[0], strlen("add")))
		do_add(--argc, ++argv);
	else if (!strncmp("set", argv[0], strlen("set")))
		do_set(--argc, ++argv);
	else if (!strncmp("rm", argv[0], strlen("rm")))
		do_rm(--argc, ++argv);
	else if (!strncmp("flag", argv[0], strlen("flag")))
		do_flag(--argc, ++argv);
	else if (!strncmp("unflag", argv[0], strlen("unflag")))
		do_unflag(--argc, ++argv);
	else if (!strncmp("bind-e", argv[0], strlen("bind-e")))
		do_bind(--argc, ++argv, BIND_TYPE_EGR);
	else if (!strncmp("bind-i", argv[0], strlen("bind-i")))
		do_bind(--argc, ++argv, BIND_TYPE_INGR);
	else if (!strncmp("bind", argv[0], strlen("bind")))
		do_bind(--argc, ++argv, BIND_TYPE_NORM);
	else if (!strncmp("unbind-e", argv[0], strlen("unbind-e")))
		do_unbind(--argc, ++argv, BIND_TYPE_EGR);
	else if (!strncmp("unbind-i", argv[0], strlen("unbind-i")))
		do_unbind(--argc, ++argv, BIND_TYPE_INGR);
	else if (!strncmp("unbind", argv[0], strlen("unbind")))
		do_unbind(--argc, ++argv, BIND_TYPE_NORM);
	else if (!strncmp("replace", argv[0], strlen("replace")))
		do_replace(--argc, ++argv, 0);
	else if (!strncmp("replace-drop", argv[0], strlen("replace-drop")))
		do_replace(--argc, ++argv, 1);
	else if (!strncmp("subscribe", argv[0], strlen("subscribe")))
		do_subscribe(--argc, ++argv);
	else if (!strncmp("unsubscribe", argv[0], strlen("unsubscribe")))
		do_unsubscribe(--argc, ++argv);
	else
		usage();

	return 0;
}
Пример #29
0
/* Return value becomes exitcode. It's okay to not return at all */
int do_iplink(char **argv)
{
	static const char keywords[] ALIGN1 =
		"set\0""show\0""lst\0""list\0";
	int key;
	if (!*argv)
		return ipaddr_list_link(argv);
	key = index_in_substrings(keywords, *argv);
	if (key < 0)
		bb_error_msg_and_die(bb_msg_invalid_arg, *argv, applet_name);
	argv++;
	if (key == 0) /* set */
		return do_set(argv);
	/* show, lst, list */
	return ipaddr_list_link(argv);
}
Пример #30
0
int do_iplink(int argc, char **argv)
{
	if (argc > 0) {
		if (matches(*argv, "set") == 0)
			return do_set(argc-1, argv+1);
		if (matches(*argv, "show") == 0 ||
		    matches(*argv, "lst") == 0 ||
		    matches(*argv, "list") == 0)
			return ipaddr_list_link(argc-1, argv+1);
		if (matches(*argv, "help") == 0)
			usage();
	} else
		return ipaddr_list_link(0, NULL);

	fprintf(stderr, "Command \"%s\" is unknown, try \"ip link help\".\n", *argv);
	exit(-1);
}