Exemple #1
0
LOCAL void g_fprint_raw_state(
	FILE		*file,
	Locstate	state,
	int		dim)
{
	int		i;
	static	char	mname[3][3] = { "mx", "my", "mz"};

	(void) fprintf(file,"state %p\n",state);
	//(void) fprintf(file,"\t%-7s = %"FFMT" %-7s = %"FFMT"\n\t","density",
	//	            Dens(state),"energy",Energy(state));
	(void) fprintf(file,"\t%-7s = %22.16g %-7s = %22.16g\n\t","density",
		            Dens(state),"energy",Energy(state));
	for (i = 0; i < dim; i++)
	    (void) fprintf(file,"%-7s = %"FFMT" ",mname[i],Mom(state)[i]);
	(void) fprintf(file,"\n");
	(void) fprintf(file,"\ttype = %u, failed = %u\n",
	                    state_type(state),material_failure(state));
	if (debugging("prt_params"))
	    fprint_Gas_param(file,Params(state));
	else
	    (void) fprintf(file,"Gas_param = %llu\n",
		                gas_param_number(Params(state)));
	if (debugging("local_gamma"))
	{
	    (void) fprintf(file,"Local gamma set: %s\n",
			   Local_gamma_set(state) ? "YES" : "NO");
	    if (Local_gamma_set(state))
		(void) fprintf(file,"Local gamma = %"FFMT"\n",
			       Local_gamma(state));
	}
}		/*end g_fprint_raw_state*/
Exemple #2
0
/**
 * Dump the buffer to strout in hex.
 *
 * @param buf buffer
 * @param len size of buffer
 */
void mnl_dumpmsg(unsigned char *buf, size_t len)
{
	int i, c;

	if ((buf == NULL)||(len <= 0))
		return;

	c = len - (len % 4);

	char tmp[512];
	debugging(" --- %p dumping, size is %d bytes ---\n", buf, len);
	sprintf(tmp, "%08x : ", 0);
	for (i = 0;i < c;i++) {
		sprintf(tmp + strlen(tmp), "%02x ", buf[i]);
		if ( i && (i % 4 == 3) && (i % 16 < 15) && (i < len - 2))
			strcat(tmp, "| ");
		if (i && (i % 16 == 15) && (i != c - 1)) {
			debugging("%s\n", tmp);
			sprintf(tmp, "%08x : ", i);
		}
	}
	if (len % 4) {
		for (;i < len;i++)
			sprintf(tmp + strlen(tmp), "%02x ", buf[i]);
	}
	debugging("%s\n", tmp);
	debugging(" ---\n");
}
Exemple #3
0
int HidController::close() {
    if (!isOpen()) {
        qDebug() << "HID device" << getName() << "already closed";
        return -1;
    }

    qDebug() << "Shutting down HID device" << getName();

    // Stop the reading thread
    if (m_pReader == NULL) {
        qWarning() << "HidReader not present for" << getName()
                   << "yet the device is open!";
    } else {
        disconnect(m_pReader, SIGNAL(incomingData(QByteArray)),
                   this, SLOT(receive(QByteArray)));
        m_pReader->stop();
        hid_set_nonblocking(m_pHidDevice, 1);   // Quit blocking
        if (debugging()) qDebug() << "  Waiting on reader to finish";
        m_pReader->wait();
        delete m_pReader;
        m_pReader = NULL;
    }

    // Stop controller engine here to ensure it's done before the device is closed
    //  incase it has any final parting messages
    stopEngine();

    // Close device
    if (debugging()) {
        qDebug() << "  Closing device";
    }
    hid_close(m_pHidDevice);
    setOpen(false);
    return 0;
}
Exemple #4
0
void drop_local_store(void)
{
/* Here the threat issued using SynAlloc or syn_xxx materialises, and a
   lot of local store is trampled upon. */
/* N.B. drop_local_store *MUST* be called before reinit_alloc()          */
   while (synsegcnt > marklist->syn_segno)
    {    char *p = synsegbase[--synsegcnt];
#ifdef never
         if (debugging(DEBUG_2STORE))
             cc_msg("Re-using syntax store %p as binder %d\n",
                     p, (int)bindsegcnt);
#endif
/* we do not need to mess with limits here as set to SEGSIZE when used */
         if (bindsegcnt >= segmax) expand_segmax(segmax * SEGMAX_FACTOR);
         bindsegbase[bindsegcnt++] = p;
    }
    synallp = marklist->syn_allp;
    synalltop = (synallp == DUFF_ADDR) ? (char *)DUFF_ADDR
                                       : synsegbase[synsegcnt-1] + SEGSIZE;
    if (debugging(DEBUG_2STORE) && synallhwm==synallmax)
        cc_msg("Max SynAlloc %ld in $r\n",
                (long)synallmax, currentfunction.symstr);
    synallhwm = marklist->syn_hwm;
    synall2 = NULL; synall3 = NULL;
}
Exemple #5
0
int HidController::open() {
    if (isOpen()) {
        qDebug() << "HID device" << getName() << "already open";
        return -1;
    }

    // Open device by path
    if (debugging()) {
        qDebug() << "Opening HID device"
                 << getName() << "by HID path" << hid_path;
    }
    m_pHidDevice = hid_open_path(hid_path);

    // If that fails, try to open device with vendor/product/serial #
    if (m_pHidDevice == NULL) {
        if (debugging())
            qDebug() << "Failed. Trying to open with make, model & serial no:"
                << hid_vendor_id << hid_product_id << hid_serial;
        m_pHidDevice = hid_open(hid_vendor_id, hid_product_id, hid_serial_raw);
    }

    // If it does fail, try without serial number WARNING: This will only open
    // one of multiple identical devices
    if (m_pHidDevice == NULL) {
        qWarning() << "Unable to open specific HID device" << getName()
                   << "Trying now with just make and model."
                   << "(This may only open the first of multiple identical devices.)";
        m_pHidDevice = hid_open(hid_vendor_id, hid_product_id, NULL);
    }

    // If that fails, we give up!
    if (m_pHidDevice == NULL) {
        qWarning()  << "Unable to open HID device" << getName();
        return -1;
    }

    setOpen(true);
    startEngine();

    if (m_pReader != NULL) {
        qWarning() << "HidReader already present for" << getName();
    } else {
        m_pReader = new HidReader(m_pHidDevice);
        m_pReader->setObjectName(QString("HidReader %1").arg(getName()));

        connect(m_pReader, SIGNAL(incomingData(QByteArray)),
                this, SLOT(receive(QByteArray)));

        // Controller input needs to be prioritized since it can affect the
        // audio directly, like when scratching
        m_pReader->start(QThread::HighPriority);
    }

    return 0;
}
Exemple #6
0
static void cleanup(void)
{
  bind_cleanup();
  pp_tidyup();

  if (debugging(DEBUG_STORE))
  {
#ifndef TARGET_IS_HELIOS
      fprintf( stderr,"Time: %ldcs front-end %ldcs back-end\n",
               (long) tmuse_front,(long) tmuse_back);
#endif
      show_store_use();
  }

  cg_tidy();

#ifndef NO_OBJECT_OUTPUT
# ifdef COMPILING_ON_ACORN_KIT
  {   bool have_obj = (objstream != NULL);
      /* objstream cannot be stdout, so cc_close does a spurious test. */
      cc_close(&objstream, objectfile);
#   ifdef COMPILING_ON_RISC_OS
      if (have_obj) set_time_stamp(objectfile, YES);
#   endif
#   ifdef COMPILING_ON_UNIX
      if (have_obj && system_flavour != NULL)
      {   char *cmd;
          cmd = GlobAlloc(SU_Other,
                          24 + strlen(system_flavour) + strlen(objectfile));
          sprintf(cmd,"/usr/bin/symrename -%s %s",system_flavour,objectfile);
          system(cmd);
      }
#   endif
  }
# else
  cc_close(&objstream, objectfile);
# endif
#endif

#ifndef NO_ASSEMBLER_OUTPUT
  cc_close(&asmstream, asmfile);
#endif

  cc_close(&listingstream, listingfile);
  cc_close(&makestream, makefile);

  summarise();

#ifdef ENABLE_MAPSTORE
  if (debugging(DEBUG_MAPSTORE)) _mapstore();
#endif

  alloc_dispose();
}
Exemple #7
0
void alloc_dispose(void)
{
    unsigned32 count = 0;
    if (debugging(DEBUG_STORE)) cc_msg("Freeing block(s) at:");
    while (alloc_chain != NULL)
    {   char *next = *(char **)alloc_chain;
        if (debugging(DEBUG_STORE))
          cc_msg("%s %p", count++ % 8 == 0 ? "\n":"", alloc_chain);
        free(alloc_chain);
        alloc_chain = next;
    }
    if (debugging(DEBUG_STORE)) cc_msg("\n");
}
Exemple #8
0
VoidStar SynAlloc(int32 n)
{   char *p = synallp;
    n = n + 3 & ~(int32)3;     /* make n a multiple of sizeof(int) */
    if (n > SEGSIZE) syserr(syserr_overlarge_store2, (long)n);
    if (p + n > synalltop)
    {   int i;                                 /* 0..segmax */
        if (synsegcnt > 0)
            synsegptr[synsegcnt-1] = p;        /* stash highest used */
        for (i = marklist->syn_segno;; i++)    /* search for scraps  */
        {   if (i == synsegcnt)                /* nowhere big enough */
            {   p = new_synalloc_segment();
                synalltop = p + SEGSIZE;
                break;
            }
            p = synsegptr[i];                  /* hope springs eternal */
            synalltop = synsegbase[i] + SEGSIZE;
            if (p+n <= synalltop)              /* fingers crossed      */
            {   /* we have scavenged something useful - swap to current */
                char *t = synsegbase[i];
                synsegbase[i] = synsegbase[synsegcnt-1];
                synsegbase[synsegcnt-1] = t;
                synsegptr[i] = synsegptr[synsegcnt-1];
                if (debugging(DEBUG_2STORE))
                {   cc_msg("Scavenge syntax %d (%p), %ld left\n",
                            (int)i, t, (long)(synalltop-(p+n)));
                }
                break;
            }
        }
        synsegptr[synsegcnt-1] = (char *)DUFF_ADDR;
    }
    synallp = p + n;
    if ((synallhwm += n) > synallmax) synallmax = synallhwm;
    return p;
}
Exemple #9
0
/**
 * Allocate new netlink socket handle.
 *
 * @return Newly allocated netlink socket handle or NULL.
 */
struct nl_handle * mnl_handle_alloc()
{
	struct nl_handle * handle = NULL;

	if (!(handle = (struct nl_handle*) calloc(1, sizeof(*handle))))
	{
		errno = ENOMEM;
		debugging("calloc for netlink handle failed\n");
		return NULL;
	}

	handle->h_local.nl_family = AF_NETLINK;
	handle->h_peer.nl_family = AF_NETLINK;
	
	static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
	static int counter = 0;
	
	pthread_mutex_lock(&lock);
	int c = counter++;
	if (counter > 127)
		counter = 0;
	pthread_mutex_unlock(&lock);
	
	handle->h_local.nl_pid = (pthread_self() << 24 | getpid() << 8) + c;

	handle->h_seq_expect = handle->h_seq_next = time(0);
	return handle;
}
Exemple #10
0
/**
 * Remove directory, warning only when it cannot be done for a reason other
 * than it not being empty.
 */
static void
tth_cache_dir_rmdir(const char *path)
{
	if (debugging(0))
		g_message("%s(): removing TTH cache directory %s", G_STRFUNC, path);

	/*
	 * To avoid any conflicts with another thread attempting to create a
	 * file under that directory, take a lock.
	 *
	 * Note that there is a race condition between the traversal that detects
	 * the directory is empty and the time we actually attempt to remove it.
	 * Hence, we silence any error having to deal with the directory being
	 * non-empty and therefore non-removable.
	 */

	TTH_PATH_LOCK;

	if (-1 == rmdir(path) && ENOTEMPTY != errno) {
		g_warning("%s(): cannot remove TTH cache directory %s: %m",
			G_STRFUNC, path);
	}

	TTH_PATH_UNLOCK;
}
Exemple #11
0
EXPORT void start_clock(
	const char	*s)
{
	int	i;

	if (!debugging("CLOCK"))
	    return;

	if (cputime == NULL)
	{
	    MAX_TIMES = 40;
	    cputime = (double*)malloc(MAX_TIMES*sizeof(double));
	    zero_scalar(cputime,MAX_TIMES*sizeof(double));
	}

	if  (top >= MAX_TIMES)
	{
	    double	*new_cputime;
	    int	NEW_MAX_TIMES = 2*MAX_TIMES;

	    new_cputime = (double*)malloc(NEW_MAX_TIMES*sizeof(double));
	    zero_scalar(new_cputime,NEW_MAX_TIMES*sizeof(double));
	    for (i = 0; i < MAX_TIMES; i++)
	    	new_cputime[i] = cputime[i];
	    MAX_TIMES = NEW_MAX_TIMES;
	}

	for (i = 0; i < top; i++)
	    (void) printf("  ");
	(void) printf("CLOCK           (%s)\n",s);
	cputime[top] = cpu_seconds();
	top++;
}		/*end start_clock*/
int daemon_detach(const char * ident)
{
	if (!svc_mode) {
		if (ident) {
			// Print help
			FILE * f = ( isatty(fileno(stdout)) ? stdout
					   : isatty(fileno(stderr)) ? stderr : NULL);
			if (f)
				daemon_help(f, ident, "now detaches from console into background mode");
		}
		// Signal detach to parent
		if (sig_event(EVT_DETACHED) != 1) {
			if (!debugging())
				return -1;
		}
		daemon_disable_console();
	}
	else {
		// Signal end of initialization to service control manager
		service_report_status(SERVICE_RUNNING, 0);
		reopen_stdin = reopen_stdout = reopen_stderr = 1;
	}

	return 0;
}
Exemple #13
0
/* VARARGS */
EXPORT	void debug_print(
	const char *funcname,
	const char *fmt,
	...)
{
	va_list ap;
	int i;
	char buf[1000];
	char *debug_l;

	if (db_mode == NONE)
	    return;


	if (debugging(funcname))
	{
	    va_start(ap, fmt);
	    (void) vfprintf(debug_output,fmt,ap);
	    va_end(ap);
	}
	va_start(ap, fmt);
	(void) vsprintf(buf,fmt,ap);
	va_end(ap);
	debug_l = debug_lines[curr_line];
	(void) sprintf(debug_l,"%-10s",funcname);
	(void) strcpy(debug_l+10,"| ");
	for(i=0; i<(MAX_LINE_LEN-12) && (debug_l[i+12] = buf[i]); ++i) ;
	debug_l[i+12] = '\0';
	++curr_line;
	if (curr_line == MAX_DEBUG_LINES)
	{
	    curr_line=0;
	    looped = 1;
	}
}		/*end debug*/
Exemple #14
0
static PathElement *mk_path_element(PathElement *link, int flags, char *name)
{ PathElement *p;
  if (debugging(DEBUG_FILES))
    cc_msg("mk_path_element(%s)\n", name);
  p = (PathElement *) ccom_alloc((int32)strlen(name) + sizeof(PathElement));
  p->link = link;
  p->flags = flags;
  strcpy(p->name, name);
  return p;
}
Exemple #15
0
static char *new_synalloc_segment(void)
{
    char *w;
    if (synsegcnt >= segmax) expand_segmax(segmax * SEGMAX_FACTOR);
    if (bindsegcur < bindsegcnt)
    {   w = bindsegbase[--bindsegcnt];
        if (debugging(DEBUG_2STORE) && synsegcnt>0)
            cc_msg("Syntax store %d from binder size %ld at %p\n",
                    (int)synsegcnt, (long)SEGSIZE, w);
    }
    else
    {   w = (char *)cc_alloc(SEGSIZE);
        if (debugging(DEBUG_STORE))
            cc_msg("Syntax store alloc %d size %ld at %p (%s in $r)\n",
                    (int)synsegcnt, (long)SEGSIZE, w,
                    phasename, currentfunction.symstr);
    }
    return synsegbase[synsegcnt++] = w;
}
Exemple #16
0
/**
 * Connect to CALM device.
 *
 * @param nl netlink handle for the communication
 * @param groups -
 *
 * @return Connection state (0: ok, -1: error)
 */
int mnl_connect(struct nl_handle *nl, int groups)
{
	socklen_t addrlen;

	if (nl == NULL)
		return CALM_ERR_COMM;

	if (groups)
		nl->h_local.nl_groups = groups;

	if ((nl->h_fd = socket(nl->h_local.nl_family, SOCK_RAW, NETLINK_GENERIC)) < 0) {
		debugging("socket(AF_NETLINK, ...) failed\n");
		return CALM_ERR_COMM;
	}
	
	if (bind(nl->h_fd, (struct sockaddr*) &nl->h_local, sizeof(nl->h_local)) < 0) {
		debugging("bind() failed\n");
		return CALM_ERR_COMM;
	}

	addrlen = sizeof(nl->h_local);
	if (getsockname(nl->h_fd, (struct sockaddr *) &nl->h_local, &addrlen) < 0) {
		debugging("getsockname failed\n");
		return CALM_ERR_COMM;
	}

	if (addrlen != sizeof(nl->h_local)) {
		errno = EADDRNOTAVAIL;
		debugging("Invalid address length\n");
		return CALM_ERR_COMM;
	}

	if (nl->h_local.nl_family != AF_NETLINK) {
		errno = EPFNOSUPPORT;
		debugging("Address format not supported\n");
		return CALM_ERR_COMM;
	}

	nl->h_proto = NETLINK_GENERIC;

	return 0;
}
Exemple #17
0
static char *new_global_segment(void)
{
    char *w;
/* I will recycle a segment that had been used for local space if there  */
/* are any such available.                                               */
    if (bindsegcur < bindsegcnt)
    {   w = bindsegbase[--bindsegcnt];
        if (debugging(DEBUG_STORE))
            cc_msg("Global store %d from binder size %ld at %p\n",
                    (int)globallcnt, (long)SEGSIZE, w);
    }
    else
    {   w = (char *)cc_alloc(SEGSIZE);
        if (debugging(DEBUG_STORE))
            cc_msg("Global store alloc %d size %ld at %p (in $r)\n",
                    (int)globallcnt, (long)SEGSIZE, w, currentfunction.symstr);
    }
    globallcnt++;
    globallp = w, globalltop = w + SEGSIZE;
    return w;
}
Exemple #18
0
static char *new_bindalloc_segment(void)
{
    if (bindsegcur >= bindsegcnt)
    {   char *w = (char *)cc_alloc(SEGSIZE);
        if (bindsegcnt >= segmax) expand_segmax(segmax * SEGMAX_FACTOR);
        if (debugging(DEBUG_STORE))
            cc_msg("Binder store alloc %d size %ld at %p (%s in $r)\n",
                    (int)bindsegcnt, (long)SEGSIZE, w,
                    phasename, currentfunction.symstr);
        bindsegbase[bindsegcnt++] = w;
    }
    return bindsegbase[bindsegcur++];
}
Exemple #19
0
/**
 * Cleanup the TTH cache by removing needless entries.
 */
void
tth_cache_cleanup(void)
{
	if (0 == atomic_int_inc(&tth_cache_cleanups)) {
		int id = thread_create(tth_cache_cleanup_thread,
					NULL, THREAD_F_DETACH | THREAD_F_WARN, THREAD_STACK_MIN);
		if (-1 == id)
			atomic_int_dec(&tth_cache_cleanups);
	} else if (debugging(0)) {
		g_warning("%s(): concurrent cleanup in progress", G_STRFUNC);
		atomic_int_dec(&tth_cache_cleanups);
	}
}
Exemple #20
0
/**
 * Send a netlink message, and receive the reply
 *
 * @param nl netlink handle
 * @param msg netlink message
 * @param msg_len netlink message length
 * @param buf reply buffer
 * @param len size of reply buffer
 *
 * @return
 */
int mnl_send(struct nl_handle *nl, unsigned char *msg, int msg_len, unsigned char **buf, int *len)
{
	int ret = CALM_ERR_OTHER;
	struct ucred *creds = NULL;

	if (mnl_sendto(nl, msg, msg_len) < 0) {
		debugging("unable to send message to the kernel.\n");
		return CALM_ERR_COMM;
	}
	//debugging("waiting for the answer.\n");
	if ((*len = mnl_recv(nl, NULL, buf, &creds)) < 0) {
		debugging("error in message receiving.\n");
		return CALM_ERR_COMM;
	}
	//debugging("check answer.\n");
	if ( (ret = mnl_checkmsg(*buf, 0)) < 0) {
		debugging("maybe error in message checking: %d\n", ret);
		return ret;
	}

	return 0;
}
Exemple #21
0
static FILE *try_instore_file(char *file, bool *sf)
{   FILE *include_file;
    if (debugging(DEBUG_FILES)) cc_msg("Try instore file '%s'\n", file);
    include_file = open_builtin_header(file, sf);
    if (include_file != NULL)
    {   show_h_line(1, file, NO);
#ifdef TARGET_IS_HELIOS
        push_include(NULL, file, PE_SYS);
#else
        push_include(NULL, file);
#endif
    }
    return include_file;
}
Exemple #22
0
/**
 * Check answer.
 *
 * Don't check the content of the message (CALM_A_ERR attribute)
 *
 * @param buf answer's buffer
 * @param ci_id CI IDD
 *
 * @return error code (0: ok)
 */
int mnl_checkmsg2(unsigned char *buf, uint32_t ci_id)
{
	struct nlmsghdr *msg = (struct nlmsghdr *)buf;
	struct nlmsgerr *err = (struct nlmsgerr *)(buf + sizeof(struct nlmsghdr));
	//struct calm_head *hdr = (struct calm_head *)(buf + sizeof(struct nlmsghdr) + sizeof(struct genlmsghdr));

	if (buf == NULL) {
		debugging(" ! wrong parameters.\n");
		return CALM_ERR_PARSE;
	}

	if (msg->nlmsg_type == NLMSG_ERROR) {
		debugging(" ! nlmsg error %d (%s)\n", err->error, strerror(-1 * err->error));
        last_nlmsg_error = err->error;
		return CALM_ERR_LOW;
	}

	if (msg->nlmsg_type != CALM_FAMILY) {
		debugging(" ! message type mismatch.\n");
		return CALM_ERR_FAMILY;
	}

	/*if (ci_id && (ci_id != hdr->ci_id)) {
		debugging(" ! ci_id mismatch\n");
		return -1;
	}*/

	uint32_t *len = (uint32_t *)buf;
	mnl_attr_t *attr = mnl_nextattr(buf, *len, NULL);
	if (attr == NULL) {
		debugging(" ! unable to extract first attribute from the answer.\n");
		return CALM_ERR_PARSE;
	}
	free(attr);

	return 0;
}
Exemple #23
0
/**
 * Generate netlink message header.
 *
 * @param cmd CALM command
 * @param ci_id requested CI's id
 * @param msg_len size of netlink's message buffer
 *
 * @return netlink message
 *
 * @see mnl_end
 */
unsigned char *mnl_generatemsghdr(int cmd, unsigned int ci_id, int *msg_len)
{
	struct nlmsghdr *msg = NULL;
	struct genlmsghdr *hdr = NULL;
	struct calm_head *chdr = NULL;
	//struct nlattr *nla = NULL;

	if (msg_len == NULL) {
		debugging(" ! wrong parameters.\n");
		return NULL;
	}

	*msg_len = sizeof(struct nlmsghdr) + sizeof(struct genlmsghdr) + sizeof(struct calm_head);

	if ((msg = calloc(1, *msg_len)) == NULL) {
		debugging(" ! not enough memory.\n");
		return NULL;
	}

	/* add netlink header */
	msg->nlmsg_len = *msg_len;
	msg->nlmsg_type = CALM_FAMILY;
	msg->nlmsg_flags = NLM_F_REQUEST;
	msg->nlmsg_seq = 0;
	msg->nlmsg_pid = getpid();

	/* add generic netlink header */
	hdr = (struct genlmsghdr *)(((unsigned char *)msg) + sizeof(struct nlmsghdr));
	hdr->cmd = cmd;
	hdr->version = CALM_VERSION;

	/* add CALM header */
	chdr = (struct calm_head *)(((unsigned char *)msg) + sizeof(struct nlmsghdr) + sizeof(struct genlmsghdr));
	chdr->ci_id = ci_id;

	return (unsigned char *)msg;
}
Exemple #24
0
EXPORT	int	return_advance_front(
	Front		*front,
	Front		**newfront,
	int		status,
	const char	*fname)
{
	if (front->pp_grid && front->pp_grid->nn > 1)
 	    status = syncronize_time_step_status(status,front->pp_grid);

	if (debugging("final_front"))
	{
	    print_Front_structure(front);
	    print_Front_structure(*newfront);
	}
	if (status != GOOD_STEP)
	{
	    free_front(*newfront);
	    *newfront = NULL;
	}
	else if (front->_EnforceFlowSpecifedStates != NULL)
	{
	    (*front->_EnforceFlowSpecifedStates)(*newfront);
	}
	if (debugging("trace"))
        {
            int dim = front->rect_grid->dim;
            (void) printf("Maximum propagated scaled distance = %f\n",
                        *(front->max_scaled_propagation));
            print_general_vector("Max propagated point: ",
                        front->max_prop_point,dim,"\n");
        }
	debug_front("final_front","after EnforceFlowSpecifedStates():",
	           *newfront);
	debug_print("front","Left %s\n",fname);
	return status;
}		/*end return_advance_front*/
Exemple #25
0
EXPORT	int reg_to_mach_diff_reconfigure(
	O_CURVE		**newc,
	O_CURVE		**oldc,
	NODE		*oldn)
{
	int		i;

	debug_print("mach_diff","Entering reg_to_mach_diff_reconfigure()\n");
	if (debugging("mach_diff"))
	{
	    (void) printf("WARNING in diffraction_node_propagate(), "
	                  "bifurcation from regular diffraction "
	                  "to mach difraction.\n");
	}

	if (newc[5]->orient == POSITIVE_ORIENTATION)
	{
	    start_status(oldc[5]->curve) = INCIDENT;
	    start_status(newc[5]->curve) = INCIDENT;
	}
	else
	{
	    end_status(oldc[5]->curve) = INCIDENT;
	    end_status(newc[5]->curve) = INCIDENT;
	}
	if (newc[0]->orient == POSITIVE_ORIENTATION)
	{
	    start_status(oldc[0]->curve) = TRANSMITTED;
	    start_status(newc[0]->curve) = TRANSMITTED;
	}
	else
	{
	    end_status(oldc[0]->curve) = TRANSMITTED;
	    end_status(newc[0]->curve) = TRANSMITTED;
	}

		/* untrack any reflected waves */

	for (i = 1; i < 4; i++)
	    if (newc[i]->curve != NULL)
	    	untracked_hyper_surf(newc[i]->curve) = YES;

	node_type(oldn) = TRANSMISSION_NODE;

	debug_print("mach_diff","Leaving reg_to_mach_diff_reconfigure()\n");
	return REPEAT_TIME_STEP_NODE;
}		/*end reg_to_mach_diff_reconfigure*/
Exemple #26
0
void alloc_mark(void)           /* @@@ not used essentially for C       */
{
    Mark *p;
    if ((p = freemarks) != NULL)
        freemarks = p->prev;
    else
        p = (Mark *) GlobAlloc(SU_Other, sizeof(Mark));

    p->prev = marklist; marklist = p;
    p->syn_segno = synsegcnt;
    p->syn_allp = synallp; p->syn_hwm = synallhwm;
    p->bind_segno = bindsegcur;
    p->bind_allp = bindallp; p->bind_hwm = bindallhwm;

    if (debugging(DEBUG_STORE))
        cc_msg("Mark %d, %p, %lx :: %d, %p, %lx\n",
                synsegcnt, synallp, (long)synallhwm,
                bindsegcur, bindallp, (long)bindallhwm);
}
Exemple #27
0
LOCAL void g_fprint_raw_Estate(
	FILE		*file,
	Locstate	state,
	int		dim)
{
	int		i;
	static	char	vname[3][3] = { "vx", "vy", "vz"};

	(void) fprintf(file,"\tdensity = %"FFMT" energy = %"FFMT" ",
		            Dens(state),Energy(state));
	for (i = 0; i < dim; i++)
	    (void) fprintf(file,"%-8s = %"FFMT" ",vname[i],Vel(state)[i]);
	if (debugging("prt_params"))
	    fprint_Gas_param(file,Params(state));
	else
	    (void) fprintf(file,"Gas_param = %llu\n",
		                gas_param_number(Params(state)));

}		/*end g_fprint_raw_Estate*/
Exemple #28
0
VoidStar GlobAlloc(StoreUse t, int32 n)
{   char *p = globallp;
    n = n + 3 & ~(int32)3;     /* make n a multiple of sizeof(int) */
    if (n > SEGSIZE)
    {   /* Big global store requests get a single oversize page.        */
        p = (char *)cc_alloc(n);
        if (debugging(DEBUG_STORE))
            cc_msg("Global overlarge store alloc size %ld at %p (in $r)\n",
                    (long)n, p, currentfunction.symstr);
        globallxtra += n;               /* could update globallcnt?     */
    }
    else
    {   if (p+n > globalltop)
            stuse_waste += globalltop-p,
            p = new_global_segment();
        globallp = p + n;
    }
    stuse[(int)t] += n;
    return p;
}
Exemple #29
0
LOCAL bool diff_turn_ang(
	float		p,
	float		*ans,
	POINTER		parameters)
{
	Locstate	st0 = ((DT_ANG_PARAMS *) parameters)->st0;
	Locstate	st1 = ((DT_ANG_PARAMS *) parameters)->st1;
	float		M0sq = 	((DT_ANG_PARAMS *) parameters)->M0sq;
	float		M1sq = 	((DT_ANG_PARAMS *) parameters)->M1sq;
	float		sign0 = ((DT_ANG_PARAMS *) parameters)->sign0;
	float		sign1 = ((DT_ANG_PARAMS *) parameters)->sign1;
	float		theta0, theta1;

	debug_print("dt_ang","Entered diff_turn_ang()\n");
	debug_print("dt_ang","\tp = %g\n",p);
	
	if (steady_state_wave_curve(p,M0sq,&theta0,st0) == FUNCTION_FAILED)
	{
		screen("WARNING in diff_turn_ang(), ");
		screen("steady_state_wave_curve() failed\n");
		return FUNCTION_FAILED;
	}
	if (steady_state_wave_curve(p,M1sq,&theta1,st1) == FUNCTION_FAILED)
	{
		screen("WARNING in diff_turn_ang(), ");
		screen("steady_state_wave_curve() failed\n");
		return FUNCTION_FAILED;
	}
	
	*ans = sign0*theta0 - sign1*theta1;

	if (debugging("dt_ang"))
	{
		print_angle("\ttheta0 =",theta0,"\n");
		print_angle("\ttheta1 =",theta1,"\n");
		print_angle("\tans =",*ans,"\n");
	}
	debug_print("dt_ang","Left diff_turn_ang()\n");
	return FUNCTION_SUCCEEDED;
}		/*end diff_turn_ang*/
Exemple #30
0
/* #ifdef PASCAL_OR_FORTRAN -- comment out? */
void alloc_unmark(void)
{
    Mark *p = marklist;
    if (p->prev == NULL) syserr(syserr_alloc_unmark);
    if (synsegcnt > p->syn_segno)
        syserr(syserr_alloc_unmark1);
    marklist = p->prev;
    p->prev = freemarks; freemarks = p;
    synsegcnt = p->syn_segno; synallp = p->syn_allp;
    synalltop = (synallp == DUFF_ADDR) ? (char *)DUFF_ADDR
                                       : synsegbase[synsegcnt-1] + SEGSIZE;
    synallhwm = p->syn_hwm;
    bindsegcur = p->bind_segno; bindallp = p->bind_allp;
    bindalltop = (bindallp == DUFF_ADDR) ? (char *)DUFF_ADDR
                                         : bindsegbase[bindsegcur-1] + SEGSIZE;
    bindallhwm = p->bind_hwm;

    if (debugging(DEBUG_STORE))
        cc_msg("Unmark %d, %p, %lx :: %d, %p, %lx\n",
                synsegcnt, synallp, (long)synallhwm,
                bindsegcur, bindallp, (long)bindallhwm);
}