Пример #1
0
static int __init ar_init_module(void)
{
	freq = (boot_cpu_data.bus_clock / 1000000);
	printk("arv: Bus clock %d\n", freq);
	if (freq != 50 && freq != 75)
		freq = DEFAULT_FREQ;
	return ar_init();
}
Пример #2
0
static void vobj_readconv(struct GlobalVars *gv,struct LinkFile *lf)
{
  if (lf->type == ID_LIBARCH) {
    if (ar_init(&ai,(char *)lf->data,lf->length,lf->filename)) {
      while (ar_extract(&ai)) {
        lf->objname = allocstring(ai.name);
        vobj_read(gv,lf,(uint8_t *)ai.data);
      }
    }
    else
      ierror("vobj_readconv(): archive %s corrupted since last access",
             lf->pathname);
  }
  else {
    lf->objname = lf->filename;
    vobj_read(gv,lf,lf->data);
  }
}
Пример #3
0
static int vobj_identify(char *name,uint8_t *p,unsigned long plen,uint8_t e)
{
  int id = ID_OBJECT;

  if (ar_init(&ai,(char *)p,plen,name)) {
    /* library archive detected, extract 1st archive member */
    id = ID_LIBARCH;
    if (!(ar_extract(&ai))) {
      error(38,name);  /* empty archive ignored */
      return ID_IGNORE;
    }
    p = (uint8_t *)ai.data;
    plen = ai.size;
  }

  if (plen>4 && p[0]==0x56 && p[1]==0x4f && p[2]==0x42 &&
      p[3]==0x4a && p[4]==e) {
    return id;
  }

  return ID_UNKNOWN;
}
Пример #4
0
int stab_evaluate (stabentry def, int * result)
{ /* evaluate a definition of the symbol table */
  ar warehouse;
  hcons hc;
  int err;

  if (def == NULL) {
    FI_errno = FI_BUGERR;
    return 0;
  }
  /* initialize the activation records warehouse and the
     appropriate hash-consing table */
  if (!ar_init (&warehouse) || !hc_hashinit (&hc, 10))
    return 0;
  /* evaluate definition. initial tag [] is represented by NULL. */
  err = tern_evaluate (def -> definition, result, NULL, hc, warehouse);
  err += ar_delete (warehouse);
  err += hc_hashdelete (hc);
  if (err == 3)
    return 1;
  return 0;
}
Пример #5
0
static void armle_readconv(struct GlobalVars *gv,struct LinkFile *lf)
/* Read ELF-ARM little-endian executable / object / shared obj. */
{
  if (lf->type == ID_LIBARCH) {
    struct ar_info ai;

    if (ar_init(&ai,(char *)lf->data,lf->length,lf->filename)) {
      while (ar_extract(&ai)) {
        lf->objname = allocstring(ai.name);
        elf32_check_ar_type(fff[lf->format],lf->pathname,
                            (struct Elf32_Ehdr *)ai.data,
                            ELFCLASS32,ELFDATA2LSB,ELF_VER,1,EM_ARM);
        elf32_parse(gv,lf,(struct Elf32_Ehdr *)ai.data,armle_reloc_elf2vlink);
      }
    }
    else
      ierror("armle_readconv(): archive %s corrupted since last access",
             lf->pathname);
  }
  else {
    lf->objname = lf->filename;
    elf32_parse(gv,lf,(struct Elf32_Ehdr *)lf->data,armle_reloc_elf2vlink);
  }
}
Пример #6
0
int main(void) {
	int i, N, L,method;
	double *inp;
	int p;
	double *phi;
	double *xpred, *amse;

	ar_object obj;
	p = 0;


	L = 5;

	phi = (double*)malloc(sizeof(double)* p);

	xpred = (double*)malloc(sizeof(double)* L);
	amse = (double*)malloc(sizeof(double)* L);

	FILE *ifp;
	double temp[2000];

	ifp = fopen("seriesA.txt", "r");
	i = 0;
	if (!ifp) {
		printf("Cannot Open File");
		exit(100);
	}
	while (!feof(ifp)) {
		fscanf(ifp, "%lf \n", &temp[i]);
		i++;
	}
	N = i;

	inp = (double*)malloc(sizeof(double)* N);
	//wmean = mean(temp, N);

	for (i = 0; i < N; ++i) {
		inp[i] = temp[i];
		//printf("%g \n",inp[i]);
	}

	method = 0; // method 0 - Yule Walker, Method 1 - Burg, Method 2, MLE (Box-Jenkins)
	obj = ar_init(method, N);
	ar_exec(obj, inp);
	ar_summary(obj);
	// Predict the next 5 values using the obtained ARIMA model
	ar_predict(obj, inp, L, xpred, amse);
	printf("\n");
	printf("Predicted Values : ");
	for (i = 0; i < L; ++i) {
		printf("%g ", xpred[i]);
	}
	printf("\n");
	printf("Standard Errors  : ");
	for (i = 0; i < L; ++i) {
		printf("%g ", sqrt(amse[i]));
	}
	printf("\n");

	ar_free(obj);
	//ar_estimate(inp, N, 2);
	free(inp);
	free(phi);
	free(xpred);
	free(amse);
	return 0;

}
void Resolver :: DNS_manager()
{
    // setup a connection to the DNS (UDP or TCP)

    PRFileDesc* fd = ar_init(ARES_CALLINIT|ARES_INITSOCK);

    if (!fd)
    {
        error();
        return;
    }

    started();

    PRIntervalTime delay = PR_SecondsToInterval(1);
    PRPollDesc pfd;

    pfd.fd = afd;
    pfd.in_flags = PR_POLL_READ;

    // wake up periodically to expire clients

    while(PR_TRUE)
    {        
        switch (PR_Poll(&pfd, 1, delay))
        {
            case -1: // fail
            case 0:  // timeout
                break;

            default:
                // if there's data, let ar_receive figure out where to route it
                // read response from the DNS server
                if (pfd.out_flags & PR_POLL_READ)
                    ar_receive();
                break;
        }
        
        PRIntervalTime now = PR_IntervalNow();

        DNShash.start_enum();
        DNSSession* session;

        // enumerate session hash table 
        while (session = DNShash.getNextSession())
        {
            if (PR_TRUE == session->hasSendFailed() )
            {
                DNShash.removeCurrent(); // remove this session from the hash table
                session->error(); // set status and wake up client
                continue;
            }

            session->update(now); // update remaining time for each session
            if (PR_TRUE == session->hasTimedOut() )
            {
                DNShash.removeCurrent(); // remove this session from the hash table
                session->expire(); // set status and wake up client
                continue;
            }
        }
        DNShash.end_enum();
        DNShash.check();
    }
}