Exemplo n.º 1
0
//
//  Copy_Array_At_Max_Shallow: C
//
// Shallow copy an array from the given index for given maximum
// length (clipping if it exceeds the array length)
//
REBARR *Copy_Array_At_Max_Shallow(
    REBARR *original,
    REBCNT index,
    REBSPC *specifier,
    REBCNT max
){
    const REBFLGS flags = 0;

    if (index > ARR_LEN(original))
        return Make_Array_For_Copy(0, flags, original);

    if (index + max > ARR_LEN(original))
        max = ARR_LEN(original) - index;

    REBARR *copy = Make_Array_For_Copy(max, flags, original);

    REBCNT count = 0;
    const RELVAL *src = ARR_AT(original, index);
    RELVAL *dest = ARR_HEAD(copy);
    for (; count < max; ++count, ++src, ++dest)
        Derelativize(dest, src, specifier);

    TERM_ARRAY_LEN(copy, max);

    return copy;
}
Exemplo n.º 2
0
static void do_test_cstat_set_backup_list(enum protocol protocol)
{
	struct cstat *cstat;
	cstat=setup_cstat(CNAME, protocol);
	ck_assert_str_eq(CLIENTCONFDIR "/" CNAME, cstat->conffile);

	cstat->permitted=1;

	fail_unless(recursive_delete(BASE)==0);
	build_storage_dirs((struct sdirs *)cstat->sdirs,
		sd123, ARR_LEN(sd123));
	fail_unless(!cstat_set_backup_list(cstat));
	fail_unless(cstat->bu!=NULL);

	fail_unless(recursive_delete(BASE)==0);
	build_storage_dirs((struct sdirs *)cstat->sdirs,
		sd13, ARR_LEN(sd13));
	fail_unless(!cstat_set_backup_list(cstat));
	fail_unless(cstat->bu!=NULL);

	fail_unless(recursive_delete(BASE)==0);
	build_storage_dirs((struct sdirs *)cstat->sdirs,
		sd12345, ARR_LEN(sd12345));
	fail_unless(!cstat_set_backup_list(cstat));
	fail_unless(cstat->bu!=NULL);

	cstat->permitted=0;
	fail_unless(!cstat_set_backup_list(cstat));
	fail_unless(cstat->bu==NULL);

	tear_down(&cstat);
}
Exemplo n.º 3
0
static void init(void) {
	usart1_init(115200, buf_in, ARR_LEN(buf_in), buf_out, ARR_LEN(buf_out));
	rtc_init();

	sei();
	puts_P(PSTR("Init complete\n\n"));
}
Exemplo n.º 4
0
int attrs_equal_be_node(const ir_node *node1, const ir_node *node2)
{
	const backend_info_t *info1 = be_get_info(node1);
	const backend_info_t *info2 = be_get_info(node2);
	size_t                len   = ARR_LEN(info1->out_infos);
	if (ARR_LEN(info2->out_infos) != len)
		return false;

	int arity = get_irn_arity(node1);
	assert(arity == get_irn_arity(node2));
	for (int in = 0; in < arity; ++in) {
		if (info1->in_reqs[in] != info2->in_reqs[in])
			return false;
	}

	for (size_t i = 0; i < len; ++i) {
		const reg_out_info_t *out1 = &info1->out_infos[i];
		const reg_out_info_t *out2 = &info2->out_infos[i];
		if (out1->reg != out2->reg)
			return false;
		if (!reg_reqs_equal(out1->req, out2->req))
			return false;
	}

	return true;
}
Exemplo n.º 5
0
Arquivo: type.c Projeto: MatzeB/fluffy
void push_type_variable_bindings(type_variable_t *type_parameters,
                                 type_argument_t *type_arguments)
{
	type_variable_t *type_parameter;
	type_argument_t *type_argument;

	if (type_parameters == NULL || type_arguments == NULL)
		return;

	/* we have to take care that all rebinding happens atomically, so we first
	 * create the structures on the binding stack and misuse the
	 * old_current_type value to temporarily save the new! current_type.
	 * We can then walk the list and set the new types */
	type_parameter = type_parameters;
	type_argument  = type_arguments;

	int old_top = typevar_binding_stack_top();
	int top     = ARR_LEN(typevar_binding_stack) + 1;
	while (type_parameter != NULL) {
		type_t *type = type_argument->type;
		while (type->kind == TYPE_REFERENCE_TYPE_VARIABLE) {
			type_reference_t *ref = (type_reference_t*) type;
			type_variable_t  *var = ref->type_variable;

			if (var->current_type == NULL) {
				break;
			}
			type = var->current_type;
		}

		top = ARR_LEN(typevar_binding_stack) + 1;
		ARR_RESIZE(typevar_binding_t, typevar_binding_stack, top);

		typevar_binding_t *binding = & typevar_binding_stack[top-1];
		binding->type_variable     = type_parameter;
		binding->old_current_type  = type;

		type_parameter = type_parameter->next;
		type_argument  = type_argument->next;
	}
	assert(type_parameter == NULL && type_argument == NULL);

	for (int i = old_top+1; i <= top; ++i) {
		typevar_binding_t *binding       = & typevar_binding_stack[i-1];
		type_variable_t   *type_variable = binding->type_variable;
		type_t            *new_type      = binding->old_current_type;

		binding->old_current_type   = type_variable->current_type;
		type_variable->current_type = new_type;

#ifdef DEBUG_TYPEVAR_BINDING
		fprintf(stderr, "binding '%s'(%p) to ", type_variable->symbol->string,
		        type_variable);
		print_type(stderr, type_variable->current_type);
		fprintf(stderr, "\n");
#endif
	}
}
Exemplo n.º 6
0
void interactive_kernel_loop() {
    char *buff = (char*) 0x10000;
    uint32_t len = 0x20000 - 0x10000;
    char *decodebuff = (char*) 0x20000;
    uint32_t decodebufflen = 0x30000 - 0x20000;
    int status = 0;
    while (1) {
        status = uart_getln(buff, len);
        if (status == 0) {
            uart_puts(uart_newline);
            if (str_startswith(buff, "b64 ")) {
                uint32_t bytes_decoded = b64_decode(buff+4, decodebuff, decodebufflen);
                uart_puts("base64 decoded #bytes: ");
                char tmp[32];
                uint32_t tmplen = ARR_LEN(tmp);
                uart_puts(str_int_to_str(bytes_decoded, tmp, tmplen));
                uart_puts(uart_newline);
                // Copy the code of bootstrap_decoded_binary somewhere safe.
                uint32_t func_len = 64; // wild guess
                mem_cpy((uint32_t)bootstrap_decoded_binary, 0x30000, func_len);
                // Call bootstrap_decoded_binary from that safe location
                BRANCHTO(0x30000);
            } else if (str_startswith(buff, "m ")) {
                inspect_memory(buff+2);
            } else if (str_startswith(buff, "r ")) {
                inspect_reg(buff+2);
            } else if (str_startswith(buff, "icky")) {
                uart_puts(yoo);
            } else if (str_startswith(buff, "usr0")) {
                if (pr0) {
                    switch_to_user_process(pr0);
                }
            } else if (str_startswith(buff, "freloc")) {
                char tmp[32];
                uint32_t tmplen = ARR_LEN(tmp);
                uint32_t func_len = ((uint32_t) str_parse_int) - ((uint32_t) str_len);
                mem_cpy((uint32_t)str_len, 0x30000, func_len);
                uart_puts(str_int_to_str(CALL_1(0x30000, "xyz"), tmp, tmplen));
            } else if (str_startswith(buff, "version")) {
                uart_puts(version);
                uart_puts("\r\n");
            } else {
                int strlen = str_len(buff) - 1;
                int j = 0;
                for (; strlen != -1; --strlen, ++j) {
                    decodebuff[j] = buff[strlen];
                }
                decodebuff[j] = 0;
                uart_puts(decodebuff);
            }
        }
        uart_puts(uart_newline);
    }
}
Exemplo n.º 7
0
//
//  Find_In_Array_Simple: C
// 
// Simple search for a value in an array. Return the index of
// the value or the TAIL index if not found.
//
REBCNT Find_In_Array_Simple(REBARR *array, REBCNT index, const RELVAL *target)
{
    RELVAL *value = ARR_HEAD(array);

    for (; index < ARR_LEN(array); index++) {
        if (0 == Cmp_Value(value + index, target, FALSE))
            return index;
    }

    return ARR_LEN(array);
}
Exemplo n.º 8
0
int main(void)
{
    int a[] = {1, 2, 8, 9, 15, 18, 22, 35, 24, 21, 15};
    int b[] = {1, 2, 8, 9, 15, 17, 18, 19, 24, 28, 15};
    int c[] = {1, 2, 8, 9, 15, 17, 18, 19, 24, 28, 15, 12, 10};
    //int b[] = { 1, 2, 5, 7, 3, 8, 9, 10, 15, 20, 14 ,17, 21, 23, 13, 7};
    int i;

    print_result(a, ARR_LEN(a));
    print_result(b, ARR_LEN(b));
    print_result(c, ARR_LEN(c));

    return 0;
}
Exemplo n.º 9
0
static void init(void) {
	usart1_init(115200, buf_in, ARR_LEN(buf_in), buf_out, ARR_LEN(buf_out));
	sei();
	printf("Running init\n");
	int rc = sd_init();


	if (rc == 0) {
		puts_P(PSTR("Init complete\n\n"));
	} else {
		puts_P(PSTR("\n\n\nInit failed\n\n"));
		// Hard_reset();
	}
}
Exemplo n.º 10
0
unsigned get_method_param_weight(ir_entity *ent, size_t pos)
{
	if (ent->attr.mtd_attr.param_weight) {
		if (pos < ARR_LEN(ent->attr.mtd_attr.param_weight))
			return ent->attr.mtd_attr.param_weight[pos];
		else
			return null_weight;
	}

	analyze_method_params_weight(ent);

	if (pos < ARR_LEN(ent->attr.mtd_attr.param_weight))
		return ent->attr.mtd_attr.param_weight[pos];
	else
		return null_weight;
}
Exemplo n.º 11
0
//
//  Copy_Array_At_Extra_Shallow: C
//
// Shallow copy an array from the given index thru the tail.
// Additional capacity beyond what is required can be added
// by giving an `extra` count of how many value cells one needs.
//
REBARR *Copy_Array_At_Extra_Shallow(
    REBARR *original,
    REBCNT index,
    REBSPC *specifier,
    REBCNT extra,
    REBFLGS flags
){
    REBCNT len = ARR_LEN(original);

    if (index > len)
        return Make_Array_For_Copy(extra, flags, original);

    len -= index;

    REBARR *copy = Make_Array_For_Copy(len + extra, flags, original);

    RELVAL *src = ARR_AT(original, index);
    RELVAL *dest = ARR_HEAD(copy);
    REBCNT count = 0;
    for (; count < len; ++count, ++dest, ++src)
        Derelativize(dest, src, specifier);

    TERM_ARRAY_LEN(copy, len);

    return copy;
}
Exemplo n.º 12
0
//
//  Copy_Array_Core_Managed: C
//
// Copy a block, copy specified values, deeply if indicated.
//
// To avoid having to do a second deep walk to add managed bits on all series,
// the resulting array will already be deeply under GC management, and hence
// cannot be freed with Free_Unmanaged_Series().
//
REBARR *Copy_Array_Core_Managed(
    REBARR *original,
    REBCNT index,
    REBSPC *specifier,
    REBCNT tail,
    REBCNT extra,
    REBFLGS flags,
    REBU64 types
){
    if (index > tail) // !!! should this be asserted?
        index = tail;

    if (index > ARR_LEN(original)) // !!! should this be asserted?
        return Make_Array_Core(extra, flags | NODE_FLAG_MANAGED);

    return Copy_Array_Core_Managed_Inner_Loop(
        original,
        index,
        specifier,
        tail,
        extra,
        flags | NODE_FLAG_MANAGED,
        types
    );
}
Exemplo n.º 13
0
//
//  Copy_Array_Core_Managed_Inner_Loop: C
//
//
static REBARR *Copy_Array_Core_Managed_Inner_Loop(
    REBARR *original,
    REBCNT index,
    REBSPC *specifier,
    REBCNT tail,
    REBCNT extra, // currently no one uses--would it also apply deep (?)
    REBFLGS flags,
    REBU64 types
){
    assert(index <= tail and tail <= ARR_LEN(original));
    assert(flags & NODE_FLAG_MANAGED);

    REBCNT len = tail - index;

    // Currently we start by making a shallow copy and then adjust it

    REBARR *copy = Make_Array_For_Copy(len + extra, flags, original);

    RELVAL *src = ARR_AT(original, index);
    RELVAL *dest = ARR_HEAD(copy);
    REBCNT count = 0;
    for (; count < len; ++count, ++dest, ++src) {
        Clonify(
            Derelativize(dest, src, specifier),
            flags,
            types
        );
    }

    TERM_ARRAY_LEN(copy, len);

    return copy;
}
Exemplo n.º 14
0
void lower_CopyB(ir_graph *irg, unsigned max_small_sz, unsigned min_large_sz,
                 int allow_misaligns)
{
	const backend_params *bparams = be_get_backend_param();

	assert(max_small_sz < min_large_sz && "CopyB size ranges must not overlap");

	max_small_size      = max_small_sz;
	min_large_size      = min_large_sz;
	native_mode_bytes   = bparams->machine_size / 8;
	allow_misalignments = allow_misaligns;

	walk_env_t env = { .copybs = NEW_ARR_F(ir_node*, 0) };
	irg_walk_graph(irg, NULL, find_copyb_nodes, &env);

	bool changed = false;
	for (size_t i = 0, n = ARR_LEN(env.copybs); i != n; ++i) {
		lower_copyb_node(env.copybs[i]);
		changed = true;
	}
	confirm_irg_properties(irg, changed ? IR_GRAPH_PROPERTIES_CONTROL_FLOW
	                                    : IR_GRAPH_PROPERTIES_ALL);

	DEL_ARR_F(env.copybs);
}
Exemplo n.º 15
0
int initGralloc(void)
{
  L("--Loading gralloc native lib--\n");

  int i,len;
  char lib_name[64];

  len=ARR_LEN(compiled_sdks);
  for (i=0;i<len;i++) {
    sprintf(lib_name, DVNC_LIB_PATH "/libdvnc_gralloc_sdk%d.so",compiled_sdks[i]); 
    L("Loading lib: %s\n",lib_name);
    
    if (gralloc_lib) //remove previous instance
      dlclose(gralloc_lib);
    gralloc_lib = dlopen(lib_name, RTLD_NOW);
    if (gralloc_lib == NULL) {
      L("Couldnt load library %s! Error string: %s\n",lib_name, dlerror());
      continue;
    }

    init_fn_type init_gralloc = dlsym(gralloc_lib,"init_gralloc");
    if(init_gralloc == NULL) {
      L("Couldn't load init_gralloc! Error string: %s\n",dlerror());
      continue;
    }

    close_gralloc = dlsym(gralloc_lib,"close_gralloc");
    if(close_gralloc == NULL) {
      L("Couldn't load close_gralloc! Error string: %s\n",dlerror());
      continue;
    }

    readfb_gralloc = dlsym(gralloc_lib,"readfb_gralloc");
    if(readfb_gralloc == NULL) {
      L("Couldn't load readfb_gralloc! Error string: %s\n",dlerror());
      continue;
    }

    getscreenformat_gralloc = dlsym(gralloc_lib,"getscreenformat_gralloc");
    if(getscreenformat_gralloc == NULL) {
      L("Couldn't load get_screenformat! Error string: %s\n",dlerror());
      continue;
    }

    int ret = init_gralloc();
    if (ret == -1) {
      L("Gralloc method not supported by this device!\n");
      continue;
    }

    screenformat = getScreenFormatGralloc();
    if ( screenformat.width <= 0 ) {
      L("Error: I have received a bad screen size from gralloc.\n");
      continue;
    }
    return 0;
  }

  return -1;
}
Exemplo n.º 16
0
ir_op *new_ir_op(unsigned code, const char *name, op_pin_state p,
                 irop_flags flags, op_arity opar, int op_index,
                 size_t attr_size)
{
	ir_op *res = XMALLOCZ(ir_op);

	res->code      = code;
	res->name      = name;
	res->pin_state = p;
	res->attr_size = attr_size;
	res->flags     = flags;
	res->opar      = opar;
	res->op_index  = op_index;
	res->tag       = 0;

	memset(&res->ops, 0, sizeof(res->ops));
	res->ops.hash            = default_hash_node;
	res->ops.copy_attr       = default_copy_attr;
	res->ops.attrs_equal     = attrs_equal_true;
	res->ops.get_type_attr   = default_get_type_attr;
	res->ops.get_entity_attr = default_get_entity_attr;

	size_t len = ARR_LEN(opcodes);
	if ((size_t)code >= len) {
		ARR_RESIZE(ir_op*, opcodes, (size_t)code+1);
		memset(&opcodes[len], 0, (code-len+1) * sizeof(opcodes[0]));
	}
Exemplo n.º 17
0
/** \brief init and register r6 spi bus.
 *
 * \param SPI: R6 SPI, e.g: SPI1,SPI2,SPI3.
 * \param spi_bus_name: spi bus name, e.g: "spi1"
 * \return
 *
 */
rt_err_t tina_spi_bus_register(SPI_T *spi, const char *spi_bus_name)
{
    int i;

    DEBUG_PRINTF("%s -> %d\n", __FUNCTION__, __LINE__);

    RT_ASSERT(spi_bus_name != RT_NULL);

    for (i = 0; i < ARR_LEN(spis); i++)
    {
        if (spi == spis[i].spi)
        {
            bus_software_reset_disalbe(spis[i].spi_gate);
            bus_gate_clk_enalbe(spis[i].spi_gate);

            spis[i].spi_bus->parent.user_data = (void *)&spis[i];
            DEBUG_PRINTF("bus  addr: %08X\n", (rt_uint32_t)spis[i].spi_bus);
            DEBUG_PRINTF("user_data: %08X\n", (rt_uint32_t)spis[i].spi_bus->parent.user_data);
            DEBUG_PRINTF("%s -> %d\n", __FUNCTION__, __LINE__);
            rt_spi_bus_register(spis[i].spi_bus, spi_bus_name, &tina_spi_ops);
            DEBUG_PRINTF("%s -> %d\n", __FUNCTION__, __LINE__);
            return RT_EOK;
        }
    }

    DEBUG_PRINTF("%s -> %d\n", __FUNCTION__, __LINE__);

    return RT_ERROR;
}
Exemplo n.º 18
0
void read(void) {
	printf("\nrecv:\n");
	uint8_t buf[SD_BLOCKSIZE*2] = {'\0'};
	if (sd_read(buf, sector, ARR_LEN(buf)/SD_BLOCKSIZE) != 0) printf("ERROR: read error\n");
	printf("%s\n", buf);
	printf("\nend recv\n");
}
Exemplo n.º 19
0
//
//  Copy_Rerelativized_Array_Deep_Managed: C
//
// The invariant of copying in general is that when you are done with the
// copy, there are no relative values in that copy.  One exception to this
// is the deep copy required to make a relative function body in the first
// place (which it currently does in two passes--a normal deep copy followed
// by a relative binding).  The other exception is when a relativized
// function body is copied to make another relativized function body.
//
// This is specialized logic for the latter case.  It's constrained enough
// to be simple (all relative values are known to be relative to the same
// function), and the feature is questionable anyway.  So it's best not to
// further complicate ordinary copying with a parameterization to copy
// and change all the relative binding information from one function's
// paramlist to another.
//
REBARR *Copy_Rerelativized_Array_Deep_Managed(
    REBARR *original,
    REBACT *before, // references to `before` will be changed to `after`
    REBACT *after
){
    const REBFLGS flags = NODE_FLAG_MANAGED;

    REBARR *copy = Make_Array_For_Copy(ARR_LEN(original), flags, original);
    RELVAL *src = ARR_HEAD(original);
    RELVAL *dest = ARR_HEAD(copy);

    for (; NOT_END(src); ++src, ++dest) {
        if (not IS_RELATIVE(src)) {
            Move_Value(dest, KNOWN(src));
            continue;
        }

        // All relative values under a sub-block must be relative to the
        // same function.
        //
        assert(VAL_RELATIVE(src) == before);

        Move_Value_Header(dest, src);

        if (ANY_ARRAY_OR_PATH(src)) {
            INIT_VAL_NODE(
                dest,
                Copy_Rerelativized_Array_Deep_Managed(
                    VAL_ARRAY(src), before, after
                )
            );
            PAYLOAD(Any, dest).second = PAYLOAD(Any, src).second;
            INIT_BINDING(dest, after); // relative binding
        }
        else {
            assert(ANY_WORD(src));
            PAYLOAD(Any, dest) = PAYLOAD(Any, src);
            INIT_BINDING(dest, after);
        }

    }

    TERM_ARRAY_LEN(copy, ARR_LEN(original));

    return copy;
}
Exemplo n.º 20
0
END_TEST

START_TEST(test_json_send_client_specific)
{
    do_test_json_send_clients_with_backup(
        BASE "/client_specific",
        sd12345, ARR_LEN(sd12345), "cli2");
}
Exemplo n.º 21
0
//
//  Alloc_Tail_Array: C
//
// Append a REBVAL-size slot to Rebol Array series at its tail.
// Will use existing memory capacity already in the series if it
// is available, but will expand the series if necessary.
// Returns the new value for you to initialize.
//
// Note: Updates the termination and tail.
//
RELVAL *Alloc_Tail_Array(REBARR *a)
{
    EXPAND_SERIES_TAIL(SER(a), 1);
    TERM_ARRAY_LEN(a, ARR_LEN(a));
    RELVAL *last = ARR_LAST(a);
    TRASH_CELL_IF_DEBUG(last); // !!! was an END marker, good enough?
    return last;
}
Exemplo n.º 22
0
//
//  RL_Get_Value: C
// 
// Get a value from a block.
// 
// Returns:
//     Datatype of value or zero if index is past tail.
// Arguments:
//     series - block series pointer
//     index - index of the value in the block (zero based)
//     result - set to the value of the field
//
RL_API int RL_Get_Value(REBARR *array, u32 index, RXIARG *result)
{
    REBVAL *value;
    if (index >= ARR_LEN(array)) return 0;
    value = ARR_AT(array, index);
    Value_To_RXI(result, value);
    return Reb_To_RXT[VAL_TYPE_0(value)];
}
Exemplo n.º 23
0
/**
 * searches the modes obstack for the given mode and returns
 * a pointer on an equal mode already in the array, NULL if
 * none found
 */
static ir_mode *find_mode(const ir_mode *m)
{
    for (size_t i = 0, n_modes = ARR_LEN(mode_list); i < n_modes; ++i) {
        ir_mode *n = mode_list[i];
        if (modes_are_equal(n, m))
            return n;
    }
    return NULL;
}
Exemplo n.º 24
0
int register_new_token(const char *token)
{
	int token_id = ARR_LEN(token_symbols);
	
	symbol_t *symbol = symbol_table_insert(token);
	symbol->ID       = token_id;
	ARR_APP1(symbol_t*, token_symbols, symbol);

	return token_id;
}
Exemplo n.º 25
0
Arquivo: parse.c Projeto: NetSys/sts
static void
free_rule (struct parse_rule *r)
{
  ARR_FREE (r->in);
  ARR_FREE (r->out);
  array_t *arrs[] = {r->match, r->mask, r->rewrite};
  for (int i = 0; i < ARR_LEN (arrs); i++) array_free (arrs[i]);
  list_destroy (&r->deps, free_dep);
  free (r);
}
Exemplo n.º 26
0
//
//  RL_Word_String: C
// 
// Return a string related to a given global word identifier.
// 
// Returns:
//     A copy of the word string, null terminated.
// Arguments:
//     word - a global word identifier
// Notes:
//     The result is a null terminated copy of the name for your own use.
//     The string is always UTF-8 encoded (chars > 127 are encoded.)
//     In this API, word identifiers are always canonical. Therefore,
//     the returned string may have different spelling/casing than expected.
//     The string is allocated with OS_ALLOC and you can OS_FREE it any time.
//
RL_API REBYTE *RL_Word_String(u32 word)
{
    REBYTE *s1, *s2;
    // !!This code should use a function from c-words.c (but nothing perfect yet.)
    if (word == 0 || word >= ARR_LEN(PG_Word_Table.array)) return 0;
    s1 = VAL_SYM_NAME(ARR_AT(PG_Word_Table.array, word));
    s2 = OS_ALLOC_N(REBYTE, LEN_BYTES(s1) + 1);
    COPY_BYTES(s2, s1, LEN_BYTES(s1) + 1);
    return s2;
}
Exemplo n.º 27
0
static void test_cstat_set_run_status_client_crashed(enum protocol protocol)
{
	struct cstat *cstat;
	cstat=set_run_status_setup(protocol, 1 /*permitted*/);
	fail_unless(recursive_delete(BASE)==0);
	build_storage_dirs((struct sdirs *)cstat->sdirs,
		sd1w, ARR_LEN(sd1w));
	cstat_set_run_status(cstat);
	fail_unless(cstat->run_status==RUN_STATUS_CLIENT_CRASHED);
	tear_down(&cstat);
}
Exemplo n.º 28
0
static void
gen_tf (const struct parse_tf *tf, FILE *out, FILE *f_strs, const array_t *arrs,
        int narrs)
{
    char *buf_deps, *buf_ports;
    size_t sz_deps, sz_ports;
    FILE *f_ports = open_memstream (&buf_ports, &sz_ports);
    FILE *f_deps = open_memstream (&buf_deps, &sz_deps);

    int start = ftell (out);
    struct tf hdr = {ftell (f_strs) + VALID_OFS, tf->nrules};

    if (tf->prefix) fwrite (tf->prefix, 1, strlen (tf->prefix) + 1, f_strs);
    else hdr.prefix = 0;
    fwrite (&hdr, sizeof hdr, 1, out);
    /* TODO: Alignment? */

    struct rule rules[hdr.nrules];
    memset (rules, 0, sizeof rules);

    int i = 0;
    for (struct parse_rule *r = tf->rules.head; r; r = r->next, i++) {
        struct rule *tmp = &rules[i];
        tmp->idx = r->idx;
        tmp->in = gen_ports (ARR (r->in), r->in.n, f_ports);
        tmp->out = gen_ports (ARR (r->out), r->out.n, f_ports);
        tmp->match = arr_find (r->match, arrs, narrs);
        tmp->mask = arr_find (r->mask, arrs, narrs);
        tmp->rewrite = arr_find (r->rewrite, arrs, narrs);
        if (r->deps.head) tmp->deps = gen_deps (&r->deps, f_deps, f_ports, arrs, narrs);
        //tmp->desc = barfoo;
    }
    fclose (f_ports);
    fclose (f_deps);

    qsort (rules, hdr.nrules, sizeof *rules, rule_cmp);
    fwrite (rules, hdr.nrules, sizeof *rules, out);

    hdr.map_ofs = ftell (out) - start;
    gen_map (out, &tf->in_map, rules, ARR_LEN (rules));

    hdr.ports_ofs = ftell (out) - start;
    fwrite (buf_ports, 1, sz_ports, out);
    free (buf_ports);

    hdr.deps_ofs = ftell (out) - start;
    fwrite (buf_deps, 1, sz_deps, out);
    free (buf_deps);

    int end = ftell (out);
    fseek (out, start, SEEK_SET);
    fwrite (&hdr, sizeof hdr, 1, out);
    fseek (out, end, SEEK_SET);
}
Exemplo n.º 29
0
static void init(void) {
	usart1_init(115200, buf_in, ARR_LEN(buf_in), buf_out, ARR_LEN(buf_out));
	sysclock_init();
	adc_init(1, AVCC, 4);
	can_init();

	vnh2sp30_init();
	vnh2sp30_active_break_to_Vcc();

	SET_PIN_MODE(NEUT_PORT, NEUT_PIN, INPUT_PULLUP);
	SET_PIN_MODE(IGN_PORT, IGN_PIN, OUTPUT);
	IGNITION_UNCUT();

	can_subscribe(PADDLE_STATUS);
	can_subscribe(NEUTRAL_ENABLED);
	can_subscribe(GEAR_STOP_BUTTON);
	can_subscribe(RESET_GEAR_ESTIMATE);

	sei();
	puts_P(PSTR("Init complete\n\n"));
}
Exemplo n.º 30
0
ptr_access_kind get_method_param_access(ir_entity *ent, size_t pos)
{
#ifndef NDEBUG
	ir_type *mtp = get_entity_type(ent);
	bool is_variadic = get_method_variadicity(mtp) == variadicity_variadic;
	assert(is_variadic || pos < get_method_n_params(mtp));
#endif

	if (ent->attr.mtd_attr.param_access) {
		if (pos < ARR_LEN(ent->attr.mtd_attr.param_access))
			return ent->attr.mtd_attr.param_access[pos];
		else
			return ptr_access_all;
	}

	analyze_ent_args(ent);

	if (pos < ARR_LEN(ent->attr.mtd_attr.param_access))
		return ent->attr.mtd_attr.param_access[pos];
	else
		return ptr_access_all;
}