Example #1
0
WEAK int copy_to_host_already_locked(void *user_context, struct halide_buffer_t *buf) {
    if (!buf->device_dirty()) {
        return 0;  // my, that was easy
    }

    debug(user_context) << "copy_to_host_already_locked " << buf << " dev_dirty is true\n";
    const halide_device_interface_t *interface = buf->device_interface;
    if (buf->host_dirty()) {
        debug(user_context) << "copy_to_host_already_locked " << buf << " dev_dirty and host_dirty are true\n";
        return halide_error_code_copy_to_host_failed;
    }
    if (interface == NULL) {
        debug(user_context) << "copy_to_host_already_locked " << buf << " interface is NULL\n";
        return halide_error_code_no_device_interface;
    }
    int result = interface->copy_to_host(user_context, buf);
    if (result != 0) {
        debug(user_context) << "copy_to_host_already_locked " << buf << " device copy_to_host returned an error\n";
        return halide_error_code_copy_to_host_failed;
    }
    buf->set_device_dirty(false);
    halide_msan_annotate_buffer_is_initialized(user_context, buf);

    return result;
}
Example #2
0
static bta_t *_bta_read_loops(FILE *fp)
{
	bta_loop_t	*l;
	uint32_t	nloops, ncells;
	uint32_t	lnum, cnum;
	bta_t	*rval;

	debug("ftell(fp) = %x\n", ftell(fp));
	lnum = ftell(fp);

	nloops = fp_read32le(fp);
	debug("nloops = %d\n", nloops);

	rval = bta_new(nloops);
	
	for (lnum = 0; lnum < nloops; lnum++) {

		ncells = fp_read32le(fp);

		l = bta_loop_new(rval, lnum, ncells);
		for (cnum = 0; cnum < ncells; cnum++) {
			gl_list_set_at(l->cellData, cnum, 
				_bta_read_cell(fp));
		}

	}

	return rval;
}
Example #3
0
int _ol_grow_and_rehash_db(ol_database *db) {
    int i;
    ol_bucket *bucket;
    ol_bucket **tmp_hashes = NULL;

    size_t to_alloc = db->cur_ht_size * 2;
    debug("Growing DB to %zu bytes.", to_alloc);
    tmp_hashes = calloc(1, to_alloc);
    check_mem(tmp_hashes);

    struct ol_stack *orphans = NULL;
    orphans = malloc(sizeof(struct ol_stack));
    check_mem(orphans);
    orphans->next = NULL;
    orphans->data = NULL;
    int orphans_found = 0;

    int iterations = ol_ht_bucket_max(db->cur_ht_size);
    for (i = 0; i < iterations; i++) {
        bucket = db->hashes[i];
        if (bucket != NULL) {
            if (bucket->next != NULL) {
                ol_bucket *tmp_bucket = bucket;
                do {
                    spush(&orphans, tmp_bucket->next);

                    ol_bucket *next = tmp_bucket->next;
                    tmp_bucket->next = NULL;
                    tmp_bucket = next;

                    orphans_found++;
                } while (tmp_bucket->next != NULL);
            }
            /* Rehash the bucket itself. */
            _ol_rehash_insert_bucket(tmp_hashes, to_alloc, bucket);
        }
    }

    /* Take care of our orphans */
    ol_log_msg(LOG_INFO, "Have %i orphans to take care of.", orphans_found);
    do {
        ol_bucket *rebucket = spop(&orphans);
        _ol_rehash_insert_bucket(tmp_hashes, to_alloc, rebucket);

        orphans_found--;
    } while (orphans->next != NULL);
    ol_log_msg(LOG_INFO, "We now have %i orphans not accounted for.", orphans_found);

    free(orphans);
    free(db->hashes);
    db->hashes = tmp_hashes;
    db->cur_ht_size = to_alloc;
    debug("Current hash table size is now: %zu bytes.", to_alloc);
    return 0;

error:
    if (tmp_hashes != NULL)
        free(tmp_hashes);
    return -1;
}
Example #4
0
/*
 * The function that is called when our module is being inserted in
 * the running kernel.
 */
static int __init init(void)
{
	int ret;
	debug("Entering\n");
	/* Register the character devices that we will use. */
	ret = crypto_chrdev_init();
	if (ret < 0) {
		printk(KERN_WARNING "Could not initialize character devices.\n");
		goto out;
	}

	INIT_LIST_HEAD(&crdrvdata.devs);
	crdrvdata.next_minor = 0;

	/* Register the virtio driver. */
	ret = register_virtio_driver(&virtio_crypto);
	if (ret < 0) {
		printk(KERN_WARNING "Failed to register virtio driver.\n");
		goto out_with_chrdev;
	}

	debug("Leaving\n");
	return ret;

out_with_chrdev:
	crypto_chrdev_destroy();
out:
	return ret;
}
Example #5
0
uint8_t matrix_scan(void)
{

    for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
        select_row(i);
        _delay_us(30);  // without this wait read unstable value.
        matrix_row_t cols = read_cols();
        if (matrix_debouncing[i] != cols) {
            matrix_debouncing[i] = cols;
            if (debouncing) {
                debug("bounce!: "); debug_hex(debouncing); debug("\n");
            }
            debouncing = DEBOUNCE;
        }
        unselect_rows();
    }

    if (debouncing) {
        if (--debouncing) {
            _delay_ms(1);
        } else {
            for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
                matrix[i] = matrix_debouncing[i];
            }
        }
    }

    return 1;
}
Example #6
0
		void simplifyRouteTest()
		{
			int row, column;
			cin >> row >> column;
			vector<vector<int> > board(HEIGHT, vector<int>(WIDTH, 0));
			inputBoard(board);

			const int up = 0;
			const int right = 1;
			const int down = 2;
			const int left = 3;

			Route route;

			//vector<int> routes = { up, up, up, up, up, down, up, up, up, up, up, up, up
			//	, up, up, up, up, up, up, up, up, right };

			vector<int> routes = { down, down, down, down, down, up, left, down, right, down, down, up, up, up, up,
				up, up, up, up, up, up, up };

			route.push_back(routes);
			debug(route);
			vector<vector<int>> board2 = board;
			moveByRoute(board, route, row, column);
			debug(board);
			cout << endl;
			Route simplifid;
			simplifyRoutePerfectly(route, row, column, simplifid);
			//_simplifyRouteNonMoving(board, route, row, column, simplifid);
			cout << endl;
			debug(simplifid);
			moveByRoute(board2, simplifid, row, column);
			debug(board2);
		}
static void tegra_mmc_set_ios(struct mmc *mmc)
{
	struct mmc_host *host = mmc->priv;
	unsigned char ctrl;
	debug(" mmc_set_ios called\n");

	debug("bus_width: %x, clock: %d\n", mmc->bus_width, mmc->clock);

	/* Change clock first */
	mmc_change_clock(host, mmc->clock);

	ctrl = readb(&host->reg->hostctl);

	/*
	 * WIDE8[5]
	 * 0 = Depend on WIDE4
	 * 1 = 8-bit mode
	 * WIDE4[1]
	 * 1 = 4-bit mode
	 * 0 = 1-bit mode
	 */
	if (mmc->bus_width == 8)
		ctrl |= (1 << 5);
	else if (mmc->bus_width == 4)
		ctrl |= (1 << 1);
	else
		ctrl &= ~(1 << 1);

	writeb(ctrl, &host->reg->hostctl);
	debug("mmc_set_ios: hostctl = %08X\n", ctrl);
}
Example #8
0
STDMETHODIMP_(NTSTATUS) WaveStream::GetPositionRegister(OUT PKSRTAUDIO_HWREGISTER   hwRegister)
{
	PAGED_CODE();

	// need to fill-in only Register, Width and Accuracy

	hwRegister->Width=32;

	int hw_buffer_size=wave->GetAdapter()->hal->hw_full_buffer_in_samples; // in samples, 48/16 buffer, full size
	switch(wave->GetAdapter()->hal->get_current_sampling_rate_fast())
	{
		case 44100:
		case 48000: break; // nop
		case 88200:
		case 96000: hw_buffer_size*=2; break;
		case 176400:
		case 192000: hw_buffer_size*=4; break;
		default:
			debug("!!WaveStream[%d]::GetPositionRegister: %s, sampling rate undefined!\n",Pin,is_recording?"recording":"playback");
	}
	hwRegister->Accuracy=(hw_buffer_size/2)*current_pin_format.Format.nChannels*current_pin_format.Format.wBitsPerSample/8;
	  // in bytes, divisible by frame size (e.g. 4 for 2ch/16)
	  // hw_full_buffer_in_samples is full buffer in samples, accuracy is 1/2 of such buffer
	  // note: measured in source format bit depth (e.g. 16 for 16-bit pcm playback)
	  // software buffer is x2 or x4 larger than 16/48 hw buffer
      // MSDN: For example, the audio frame size for a 2-channel, 16-bit PCM stream is 4 bytes. If the position register increments
      // (by two times the frame size) once every second tick of the sample clock, the accuracy value is 8 bytes. If the position register
      // increments (by four times the frame size) once every fourth tick of the sample clock, the accuracy value is 16 bytes, and so on
    
	hwRegister->Register=&AudioPosition;

	debug("WaveStream[%d]::GetPositionRegister: %s, accuracy: %d\n",Pin,is_recording?"recording":"playback",hwRegister->Accuracy);

	return STATUS_SUCCESS;
}
Example #9
0
int clsyncmgr_watchdir_lookup(const char **const watchdir_pp, clsyncmgr_t *ctx_p)
{
	struct dirent *dirent;
	debug(4, "<%s>", *watchdir_pp);

	DIR *dir = opendir(*watchdir_pp);
	if (dir == NULL) {
		error("Cannot open directory \"%s\"", *watchdir_pp);
		return errno;
	}

	while (errno=0, (dirent=readdir(dir)) != NULL) {
		switch (dirent->d_type) {
			case DT_SOCK: {
				char buf[BUFSIZ];
				snprintf(buf, BUFSIZ, "%s/%s", *watchdir_pp, dirent->d_name);
				debug(5, "found socket: <%s>", buf);

				clsyncmgr_socketpath_connect((const char **)&buf, ctx_p);
				break;
			}
		}
	}

	if (errno)
		error("Cannot read an entry from directory \"%s\"", *watchdir_pp);

	closedir(dir);
	return 0;
}
double CorrectECalBarrelSliWinCluster::getNoiseConstantPerCluster(double aEta, uint aNumCells) {
  double param0 = 0.;
  double param1 = 0.;

  // All histograms have same binning, all bins with same size
  // Using the histogram of the first parameter to get the bin size
  unsigned index = 0;
  if (m_histoPileupConst.size() != 0) {
    int Nbins = m_histoPileupConst.at(index).GetNbinsX();
    double deltaEtaBin =
        (m_histoPileupConst.at(index).GetBinLowEdge(Nbins) + m_histoPileupConst.at(index).GetBinWidth(Nbins) -
         m_histoPileupConst.at(index).GetBinLowEdge(1)) /
        Nbins;
    double etaFirtsBin = m_histoPileupConst.at(index).GetBinLowEdge(1);
    // find the eta bin for the cell
    int ibin = floor((fabs(aEta) - etaFirtsBin) / deltaEtaBin) + 1;
    verbose() << "Current eta = " << aEta << " bin = " << ibin << endmsg;
    if (ibin > Nbins) {
      debug() << "eta outside range of the histograms! Cell eta: " << aEta << " Nbins in histogram: " << Nbins
              << endmsg;
      ibin = Nbins;
    }
    param0 = m_histoPileupConst.at(0).GetBinContent(ibin);
    param1 = m_histoPileupConst.at(1).GetBinContent(ibin);
    verbose() << "p0 = " << param0 << " param1 = " << param1 << endmsg;
  } else {
    debug() << "No histograms with noise constants!!!!! " << endmsg;
  }
  double pileupNoise = param0 * pow(aNumCells * (m_dEta / 0.01), param1);

  return pileupNoise;
}
Example #11
0
WaveStream::~WaveStream()
{
	PAGED_CODE();

	ASSERT(valid_object(this,WaveStream));

    debug("WaveStream[%d]::~WaveStream [%p]\n",Pin,this);

    enabled=false;

    if(NotificationEvent)
    {
    	debug("!! WaveStream[%d]::~WaveStream: notification event %p still allocated\n",Pin,NotificationEvent);
    	NotificationEvent=NULL;
    }

    if(wave)
    {
        // just in case
        if(valid_object(wave->GetAdapter()->hal,Hal))
        	wave->GetAdapter()->hal->remove_notification(this);

    	wave=NULL;
    }

    memset(&current_pin_format,0,sizeof(current_pin_format));

    magic=NULL;
}
Example #12
0
int main()
{    
    Octstr *os;    
    long i;    
    gw_prioqueue_t *queue;    
    
    gwlib_init();
    
    /* os = octstr_imm("iareanmsgotx"); */    
    os = octstr_imm("123456789");   

    queue = gw_prioqueue_create(my_cmp);    
    
    for (i=0; i < octstr_len(os); i++) {        
        char a[2];       
        a[0] = octstr_get_char(os, i);       
        a[1] = '\0';        
        gw_prioqueue_insert(queue, octstr_create(a));    
    }    
    
    gw_prioqueue_foreach(queue, my_dump);    
    while ((os = gw_prioqueue_remove(queue))) {        
        debug("", 0, "%s", octstr_get_cstr(os));        
        octstr_destroy(os);    
    }   
    
    debug("", 0, "gw_prioqueue_len=%ld", gw_prioqueue_len(queue));    
    
    gwlib_shutdown();    
    return 0;
}
Example #13
0
int upload_kernelcache() {
	struct stat buf;
	char kernelcache[255];
	irecv_error_t error = IRECV_E_SUCCESS;

	memset(kernelcache, '\0', 255);
	memset(&buf, '\0', sizeof(buf));
	snprintf(kernelcache, 254, "kernelcache.release.%c%c%c", 
		device->hardware_model[0], device->hardware_model[1], 
		device->hardware_model[2]);
	debug("Checking if kernelcache already exists\n");
	if (stat(kernelcache, &buf) != 0) {
		if (fetch_image(kernelcache, kernelcache) < 0) {
			error("Unable to upload kernelcache\n");
			return -1;
		}
	}

	debug("Resetting device counters\n");
	error = irecv_reset_counters(client);
	if (error != IRECV_E_SUCCESS) {
		debug("%s\n", irecv_strerror(error));
		error("Unable upload kernelcache\n");
		return -1;
	}

	error = irecv_send_file(client, kernelcache, 1);
	if (error != IRECV_E_SUCCESS) {
		debug("%s\n", irecv_strerror(error));
		error("Unable upload kernelcache\n");
		return -1;
	}

	return 0;
}
Example #14
0
int upload_firmware_image(const char* type) {
	char image[255];
	struct stat buf;
	irecv_error_t error = IRECV_E_SUCCESS;

	memset(image, '\0', 255);
	snprintf(image, 254, "%s.%s", type, device->hardware_model);

	debug("Checking if %s already exists\n", image);
	if (stat(image, &buf) != 0) {
		if (fetch_firmware_image(type, image) < 0) {
			error("Unable to upload firmware image\n");
			return -1;
		}
	}

	debug("Resetting device counters\n");
	error = irecv_reset_counters(client);
	if (error != IRECV_E_SUCCESS) {
		error("Unable to upload firmware image\n");
		debug("%s\n", irecv_strerror(error));
		return -1;
	}

	debug("Uploading %s to device\n", image);
	error = irecv_send_file(client, image, 1);
	if (error != IRECV_E_SUCCESS) {
		error("Unable to upload firmware image\n");
		debug("%s\n", irecv_strerror(error));
		return -1;
	}
	return 0;
}
Example #15
0
void test_debug() {
    //notice you don't need \n
    debug("I have Brown Hair");

    //passing in arguments like printf
    debug("I am %d years old");
}
Example #16
0
int clsyncmgr_socketpath_connect(const char **const socketpath_pp, clsyncmgr_t *ctx_p)
{
	const char *socketpath = *socketpath_pp;

	debug(5, "<%s>", socketpath);

	if (g_hash_table_lookup(ctx_p->sock_unix_ht_path, socketpath) != NULL) {
		debug(4, "already connected to <%s>, skipping", socketpath);
		return 0;
	}

	clsyncproc_t *clsyncproc_p = clsync_connect_unix(socketpath, clsyncmgr_proc_clsync, 0);
	if (clsyncproc_p == NULL) {
		warning("Cannot connect to <%s> (errno %i: %s)", socketpath, errno, strerror(errno));
		return errno;
	}

	clsyncproc_p->data = xcalloc(1, sizeof(clsyncproc_data_t));

	debug(3, "connected to <%s>", socketpath);
	socket_send_cb(clsyncproc_p->sock_p, SOCKCMD_REQUEST_INFO, proc_clsync_gotinfo, clsyncproc_p);
	g_hash_table_insert(ctx_p->sock_unix_ht_path,  strdup(socketpath), clsyncproc_p);

	return 0;
}
Example #17
0
static void DumpFD(int fd)
{
	struct timeval timeout = { 1, 0 };
	fd_set readfds;
	char buf[500];
	int len;

	FD_ZERO(&readfds);
	FD_SET(fd, &readfds);

	debug(0, "DumpFD: select on fd %d", fd);
	/* wait for something to do */
	if (select(fd + 1, &readfds, 0, 0, &timeout) == -1)
		error("select: %m");

	else if (FD_ISSET(fd, &readfds))
	{
		if ((len = read(fd, buf, sizeof buf)) == -1)
			error("Iowait: read: %m");
		else if (len == 0)
			debug(0, "eof on %d", fd);
		else
			dump(fd, "dump...", buf, len);
	}
}
Example #18
0
File: systemv.c Project: julp/banip
queue_err_t queue_close(void **p)
{
    if (NULL != *p) {
        systemv_queue_t *q;

        q = (systemv_queue_t *) *p;
        if (NULL != q->filename) { // we are the owner
            if (-1 != q->qid) {
                if (0 != msgctl(q->qid, IPC_RMID, NULL)) {
                    // TODO: error
                    debug("");
                    return QUEUE_ERR_GENERAL_FAILURE;
                }
                q->qid = -1;
            }
            if (0 != unlink(q->filename)) {
                // TODO: error
                debug("");
                return QUEUE_ERR_GENERAL_FAILURE;
            }
            free(q->filename);
            q->filename = NULL;
        }
        if (NULL != q->buffer) {
            free(q->buffer);
            q->buffer = NULL;
        }
        free(*p);
        *p = NULL;
    }

    return QUEUE_ERR_OK;
}
static void mmc_set_power(struct mmc_host *host, unsigned short power)
{
	u8 pwr = 0;
	debug("%s: power = %x\n", __func__, power);

	if (power != (unsigned short)-1) {
		switch (1 << power) {
		case MMC_VDD_165_195:
			pwr = TEGRA_MMC_PWRCTL_SD_BUS_VOLTAGE_V1_8;
			break;
		case MMC_VDD_29_30:
		case MMC_VDD_30_31:
			pwr = TEGRA_MMC_PWRCTL_SD_BUS_VOLTAGE_V3_0;
			break;
		case MMC_VDD_32_33:
		case MMC_VDD_33_34:
			pwr = TEGRA_MMC_PWRCTL_SD_BUS_VOLTAGE_V3_3;
			break;
		}
	}
	debug("%s: pwr = %X\n", __func__, pwr);

	/* Set the bus voltage first (if any) */
	writeb(pwr, &host->reg->pwrcon);
	if (pwr == 0)
		return;

	/* Now enable bus power */
	pwr |= TEGRA_MMC_PWRCTL_SD_BUS_POWER;
	writeb(pwr, &host->reg->pwrcon);
}
Example #20
0
void FrequencyManager_SetBandCodeFilter (uint8_t band, uint8_t value)
{
	debug(GUI, "FrequencyManager_SetBandCodeFilter:\n");
	s_bandTable[band].Code = value;
	debug(GUI, "band = %d, code = %d\n", band, value);
	FrequencyManager_Output_FilterCode(value);
}
static void mmc_reset(struct mmc_host *host, struct mmc *mmc)
{
	unsigned int timeout;
	debug(" mmc_reset called\n");

	/*
	 * RSTALL[0] : Software reset for all
	 * 1 = reset
	 * 0 = work
	 */
	writeb(TEGRA_MMC_SWRST_SW_RESET_FOR_ALL, &host->reg->swrst);

	host->clock = 0;

	/* Wait max 100 ms */
	timeout = 100;

	/* hw clears the bit when it's done */
	while (readb(&host->reg->swrst) & TEGRA_MMC_SWRST_SW_RESET_FOR_ALL) {
		if (timeout == 0) {
			printf("%s: timeout error\n", __func__);
			return;
		}
		timeout--;
		udelay(1000);
	}

	/* Set SD bus voltage & enable bus power */
	mmc_set_power(host, fls(mmc->cfg->voltages) - 1);
	debug("%s: power control = %02X, host control = %02X\n", __func__,
		readb(&host->reg->pwrcon), readb(&host->reg->hostctl));

	/* Make sure SDIO pads are set up */
	pad_init_mmc(host);
}
Example #22
0
/**
 * parse the set command
 */
void parseSet(char* input) {
    printf("%s\n", input);
    if (begins(input, "user ")) {
        debug("set user");
        setUser(input + 5);
        return;
    } else if (begins(input, "pass ")) {

        if (strlen(input + 5) < 1) {
            debug("ask for password");
            askPassword();
            return;
        }
        debug("set password");
        setPassword(input + 5);
        return;
    } else if (begins(input, "debug ")) {
        if (begins(input + 6, "true") || begins(input + 6, "on")) {
            setDebug(true);
        } else if (begins(input + 6, "false") || begins(input + 6, "off")) {
            setDebug(false);
        }
    } else if (begins(input, "pgpass ")) {

        if (begins(input + 7, "true") || begins(input + 7, "on")) {
            setPGPass(true);
        } else if (begins(input + 7, "false") || begins(input + 7, "off")) {
            setPGPass(false);
        }
    }
    debug("no match in set");
    printf("Don't know what you want...\n");
}
Example #23
0
/*
 * The function that is called when our module is being removed.
 * Make sure to cleanup everything.
 */
static void __exit fini(void)
{
	debug("Entering\n");
	crypto_chrdev_destroy();
	unregister_virtio_driver(&virtio_crypto);
	debug("Leaving\n");
}
Example #24
0
/** allocate small block */
static void* mem_small_allocate(struct s_arena* arena, size_t size_in_words, unsigned int nptrs){
	void* ptr;
 	struct single_bdescr* single_block = find_current_single_block(arena);
	const int block_offset_words = WORDS_OF_TYPE(struct single_bdescr);

	if((single_block->cur_words + size_in_words +1)*sizeof(void*) > BLOCK_SIZE){
		/* no space to alloc */
		/* clear trailing area */
		debug("%s : 1 single_bloc %08x cur_words %08x target %08x\n",__FUNCTION__,single_block,single_block->cur_words,(unsigned int)(((void**) single_block)+single_block->cur_words));
		*(((void**) single_block)+single_block->cur_words) = NULL;
		prepend_new_single_block(arena);
 		single_block = find_current_single_block(arena);
	}
	/* allocated ptr is now fixed. */
	ptr = (void*)((void**)single_block + ((single_block->cur_words) +1));
	single_block->cur_words += size_in_words + 1;
	debug("%s : 2 single_bloc %08x cur_words %08x target %08x\n",__FUNCTION__,single_block,single_block->cur_words,(((void**) single_block)+single_block->cur_words));
	*(((void**) single_block)+single_block->cur_words) = NULL;
	if((single_block->cur_words + 1)*sizeof(void*) < BLOCK_SIZE){
		*(((void**) single_block)+(single_block->cur_words +1)) = NULL;
	}
	if((single_block->cur_words + size_in_words +1)*sizeof(void*) > BLOCK_SIZE){
		debug("%s : 3 single_bloc %08x cur_words %08x target %08x\n",__FUNCTION__,single_block,single_block->cur_words,(((void**) single_block)+single_block->cur_words));
		/* no space to alloc */
		/* clear trailing area */
		*(((void**) single_block)+single_block->cur_words) = NULL;
		prepend_new_single_block(arena);
 		single_block = find_current_single_block(arena);
	}
	SET_SIZE(ptr,size_in_words);
	SET_NPTR(ptr,nptrs);
	debug("%s small_block size : %d size_in_words : %d\n",__FUNCTION__,size_in_words*4,size_in_words);
	return ptr;
}
Example #25
0
bool stageOneShutDown(void)
{
	debug(LOG_WZ, "== stageOneShutDown ==");

	if ( audio_Disabled() == false )
	{
		sound_CheckAllUnloaded();
	}

	proj_Shutdown();

    releaseMission();

	if (!aiShutdown())
	{
		return false;
	}

	if (!objShutdown())
	{
		return false;
	}

	grpShutDown();

	ResearchRelease();

	//free up the gateway stuff?
	gwShutDown();
	
	shutdownTerrain();

	if (!mapShutdown())
	{
		return false;
	}

	scrShutDown();
	gridShutDown();

	if ( !anim_Shutdown() )
	{
		return false;
	}

	if ( !animObj_Shutdown() )
	{
		return false;
	}

	debug(LOG_TEXTURE, "=== stageOneShutDown ===");
	pie_TexShutDown();
	// Use mod_multiplay as the default (campaign might have set it to mod_singleplayer)
	rebuildSearchPath( mod_multiplay, true );
	pie_TexInit(); // restart it

	initMiscVars();

	return true;
}
Example #26
0
/* pop object to be scavenged. */
void* find_big_object(struct s_gc* s_gc){
	struct big_bdescr* big_block = NULL;
	/* two quite similar pathes exist. but we don't merge them for later debugging. */
	if(s_gc->scavenging_big_object == NULL){
		/* not initialized :  scavenging_big_object points to the before head. */
		big_block = (struct big_bdescr*)TAILQ_FIRST(&(s_gc->big_live_queue));
		if(big_block != NULL){
			/* object to scavenge */
			s_gc->scavenging_big_object = big_block;
		} else{
			/* no object to scavenge, waiting for any object to be scavenged */
			/* if  find_small_object works well, this may not happen */
			debug("%s : no object found.\n",__FUNCTION__);
			return NULL;
		}
	}else{
		big_block = (struct big_bdescr*)TAILQ_NEXT((struct bdescr*)s_gc->scavenging_big_object,link);
		if(big_block != NULL){
			s_gc->scavenging_big_object = big_block;
		} else {
			debug("%s : no object found: big object reached to the tail\n",__FUNCTION__);
			return NULL;
		}
	}
	return (void*)(( (void**)big_block)+WORDS_OF_TYPE(struct big_bdescr));
}
Example #27
0
void eth_set_enetaddr(int num, char *addr) {
	struct eth_device *dev;
	unsigned char enetaddr[6];
	char *end;
	int i;

	debug ("eth_set_enetaddr(num=%d, addr=%s)\n", num, addr);

	if (!eth_devices)
		return;

	for (i=0; i<6; i++) {
		enetaddr[i] = addr ? simple_strtoul(addr, &end, 16) : 0;
		if (addr)
			addr = (*end) ? end+1 : end;
	}

	dev = eth_devices;
	while(num-- > 0) {
		dev = dev->next;

		if (dev == eth_devices)
			return;
	}

	debug ( "Setting new HW address on %s\n"
		"New Address is             %02X:%02X:%02X:%02X:%02X:%02X\n",
		dev->name,
		enetaddr[0], enetaddr[1],
		enetaddr[2], enetaddr[3],
		enetaddr[4], enetaddr[5]);

	memcpy(dev->enetaddr, enetaddr, 6);
}
Example #28
0
/*
 * Add reroute information to the connection data. Where the priority
 * is in the order: reroute, reroute-smsc-id, reroute-receiver.
 */
static void init_reroute(SMSCConn *conn, CfgGroup *grp)
{
    Octstr *rule;
    long i;

    if (cfg_get_bool(&conn->reroute_dlr, grp, octstr_imm("reroute-dlr")) == -1)
        conn->reroute_dlr = 0;
    info(0, "DLR rerouting for smsc id <%s> %s.", octstr_get_cstr(conn->id), (conn->reroute_dlr?"enabled":"disabled"));

    if (cfg_get_bool(&conn->reroute, grp, octstr_imm("reroute")) != -1) {
        debug("smscconn",0,"Adding general internal routing for smsc id <%s>",
              octstr_get_cstr(conn->id));
        return;
    }

    if ((conn->reroute_to_smsc = cfg_get(grp, octstr_imm("reroute-smsc-id"))) != NULL) {
         /* reroute all messages to a specific smsc-id */
         debug("smscconn",0,"Adding internal routing: smsc id <%s> to smsc id <%s>",
               octstr_get_cstr(conn->id), octstr_get_cstr(conn->reroute_to_smsc));
        return;
    }

    if ((rule = cfg_get(grp, octstr_imm("reroute-receiver"))) != NULL) {
        List *routes;

        /* create hash disctionary for this smsc-id */
        conn->reroute_by_receiver = dict_create(100, (void(*)(void *)) octstr_destroy);

        routes = octstr_split(rule, octstr_imm(";"));
        for (i = 0; i < gwlist_len(routes); i++) {
            Octstr *item = gwlist_get(routes, i);
            Octstr *smsc, *receiver;
            List *receivers;

            /* first word is the smsc-id, all other are the receivers */
            receivers = octstr_split(item, octstr_imm(","));
            smsc = gwlist_extract_first(receivers);
            if (smsc)
                octstr_strip_blanks(smsc);

            while((receiver = gwlist_extract_first(receivers))) {
                octstr_strip_blanks(receiver);
                debug("smscconn",0,"Adding internal routing for smsc id <%s>: "
                          "receiver <%s> to smsc id <%s>",
                          octstr_get_cstr(conn->id), octstr_get_cstr(receiver),
                          octstr_get_cstr(smsc));
                if (!dict_put_once(conn->reroute_by_receiver, receiver, octstr_duplicate(smsc)))
                    panic(0, "Could not set internal routing for smsc id <%s>: "
                              "receiver <%s> to smsc id <%s>, because receiver has already routing entry!",
                              octstr_get_cstr(conn->id), octstr_get_cstr(receiver),
                              octstr_get_cstr(smsc));
                octstr_destroy(receiver);
            }
            octstr_destroy(smsc);
            gwlist_destroy(receivers, octstr_destroy_item);
        }
        octstr_destroy(rule);
        gwlist_destroy(routes, octstr_destroy_item);
    }
}
Example #29
0
uint8_t _matrix_scan(void)
{
    // Right hand is stored after the left in the matirx so, we need to offset it
    int offset = isLeftHand ? 0 : (ROWS_PER_HAND);

    for (uint8_t i = 0; i < ROWS_PER_HAND; i++) {
        select_row(i);
        _delay_us(30);  // without this wait read unstable value.
        matrix_row_t cols = read_cols();
        if (matrix_debouncing[i+offset] != cols) {
            matrix_debouncing[i+offset] = cols;
            if (debouncing) {
                debug("bounce!: "); debug_hex(debouncing); debug("\n");
            }
            debouncing = DEBOUNCE;
        }
        unselect_rows();
    }

    if (debouncing) {
        if (--debouncing) {
            _delay_ms(1);
        } else {
            for (uint8_t i = 0; i < ROWS_PER_HAND; i++) {
                matrix[i+offset] = matrix_debouncing[i+offset];
            }
        }
    }

    return 1;
}
Example #30
0
/**
 * @brief Deletes a client from the client list
 *
 * Removes the specified client from the client list and then calls
 * the function _client_list_free_node to free the memory taken by the client.
 * @param client Points to the client to be deleted
 */
void
client_list_delete(t_client * client)
{
    t_client *ptr;

    ptr = firstclient;

    if (ptr == NULL) {
        debug(LOG_ERR, "Node list empty!");
    } else if (ptr == client) {
        debug(LOG_NOTICE, "Deleting %s %s token %s from client list",
              client->ip, client->mac, client->token ? client->token : "none");
        firstclient = ptr->next;
        _client_list_free_node(client);
        client_count--;
    } else {
        /* Loop forward until we reach our point in the list. */
        while (ptr->next != NULL && ptr->next != client) {
            ptr = ptr->next;
        }
        /* If we reach the end before finding out element, complain. */
        if (ptr->next == NULL) {
            debug(LOG_ERR, "Node to delete could not be found.");
        } else {
            /* Free element. */
            debug(LOG_NOTICE, "Deleting %s %s token %s from client list",
                  client->ip, client->mac, client->token ? client->token : "none");
            ptr->next = client->next;
            _client_list_free_node(client);
            client_count--;
        }
    }
}