Beispiel #1
0
void
test_using(const char *ctl, char *buf, int bytes, void (*copyf)(const void *s1, void *d, size_t bytes))
{
    int i;
    int loops;
    long long us;

    start_timing();
    for (i = 0; (i & 31) || stop_timing(0, NULL) == 0; ++i) {
	copyf(buf, buf + bytes, bytes);
    }

    loops = i * 2;
    start_timing();
    for (i = loops - 1; i >= 0; --i) {
	copyf(buf, buf + bytes, bytes);
    }
#if 0
    fpcleanup();
#endif
    stop_timing(loops, ctl);
    us = get_timing();
    printf("%s %d %5.2f MBytes/sec\n", ctl, bytes, 
	(double)loops * (double)bytes / (double)us);
}
Beispiel #2
0
xaset_t *xaset_union(pool *work_pool, xaset_t *set1, xaset_t *set2,
    size_t msize, XASET_MCOPY copyf) {
  xaset_t *newset;
  xasetmember_t *setp,*n;
  xaset_t *setv[3];
  xaset_t **setcp;

  setv[0] = set1; setv[1] = set2; setv[2] = NULL;

  if (!set1 || !set2 || (!msize && !copyf)) {
    errno = EINVAL;
    return NULL;
  }

  work_pool = (work_pool ? work_pool :
    (set1->pool ? set1->pool : set2->pool));

  if (!(newset = xaset_create(work_pool, set1->xas_compare)))
    return NULL;

  for (setcp = setv; *setcp; setcp++)
    for (setp = (*setcp)->xas_list; setp; setp=setp->next) {
      n = copyf ? copyf(setp) : (xasetmember_t*) palloc(work_pool, msize);
      if (!n)
        return NULL;			/* Could cleanup here */

      if (!copyf)
        memcpy(n, setp, msize);

      if (xaset_insert_sort(newset, n, 0) == -1)
        return NULL;
    }

  return newset;
}
Beispiel #3
0
void main()
{

	SetAddApplDir("kolibrios", abspath("install/kolibrios")+1);
	io.run("/sys/media/kiv", "\\S__/kolibrios/res/Wallpapers/In the wind there is longing.png");
	io.del("/sys/docpack");
	copyf(abspath("install/sys"), "/sys");
	RestartProcessByName("@icon", MULTIPLE);
	RestartProcessByName("@taskbar", SINGLE);
	RestartProcessByName("@docky", SINGLE);
	notify(T_END);
	io.run("/sys/tmpdisk", "a0s10");
	pause(50);
	copyf(abspath("install/tmp"), "/tmp0/1");
	ExitProcess();
}
Beispiel #4
0
xaset_t *xaset_subtract(pool *work_pool, xaset_t *set1, xaset_t *set2,
    size_t msize, XASET_MCOPY copyf) {
  xaset_t *newset;
  xasetmember_t *set1p,*set2p,*n,**pos;
  int c;

  if (!set1 || !set2 || (!msize && !copyf)) {
    errno = EINVAL;
    return NULL;
  }

  work_pool = (work_pool ? work_pool :
    (set1->pool ? set1->pool : set2->pool));

  if (!(newset = xaset_create(work_pool, set1->xas_compare)))
    return NULL;

  pos = &newset->xas_list;

  /* NOTE: xaset_insert_sort is not used here for performance
     reasons. */

  for (set1p = set1->xas_list, set2p = set2->xas_list; set1p;
      set1p = set1p->next) {
    if (!set2p || (c = set1->xas_compare(set1p, set2p)) < 0) {
      /* Copy if set2 is exhausted or set1p's "value" is less than
         set2p's. */
      n = copyf ? copyf(set1p) : (xasetmember_t *) palloc(work_pool, msize);
      if (!n)
        return NULL;			/* Could cleanup here */

      if (!copyf)
        memcpy(n, set1p, msize);

      /* Create links */
      n->prev = *pos;
      n->next = NULL;
      if (*pos)
        pos = &(*pos)->next;
      *pos = n;

    } else if (c >= 0) {

      /* Traverse set2 until we reach a point where set2 is
         exhausted or set2p is "greater" than set1p */
      while ((set2p = set2p->next) != NULL &&
            set1->xas_compare(set1p, set2p) > 0) ;

      /* In case there are dupes in set1, examine the next (if any)
         value(s) and skip if necessary */
      while (set1p->next && set1->xas_compare(set1p, set1p->next) == 0)
        set1p = set1p->next;
    }
  }

  return newset;
}
Beispiel #5
0
int main (){

    float tab[N];
    float tab2[N];
    initf(tab, N);
//    read(tab, N);
    copyf(tab, tab2, N);
    priintf(tab2, N);
    npermutf(tab2, N, 2);
    priintf(tab2, N);


    char tab3[N];
    char tab4[N];
    char tab5[N];


    initc(tab3, N);
    initc(tab4, N);
    initc(tab5, N);

    npermutc(tab4, N, 1);
    minToMaj(tab5, N);

        printc(tab3, N);
        printc(tab4, N);
        printc(tab5, N);

    mirror(tab4, N);

        printc(tab3, N);
        printc(tab4, N);
        printc(tab5, N);


    printf("%d\n", searchs(tab3, tab4, N, N));
    printf("%d\n", searchs(tab3, tab5, N, N));


    frac ax = {30, 50};
    frac bx = {30, 50};
    printf("frac %d %d\n", ax.nume, ax.deno);
    simplify(&ax);
    printf("simply frac %d %d\n", ax.nume, ax.deno);

    return 0;
}
Beispiel #6
0
void copyp(char *s,char *ss,char *sss)
	{
	int x,k=0;
	char s1[80],s2[80],s3[80],sp[80],s4[80];

		strcpy(s2,s);
		strcat(s2,sss);
		strcpy(s1,ss);
		strcat(s1,sss);
		x=mkdir(s1);
		strcpy(s3,s2);
		strcat(s3,"\\*.*");
		struct ffblk full;
		x=findfirst(s3,&full,0);
		if (x==0)
			{
			strcat(s1,"\\");
			strcat(s2,"\\");
			struct ffblk full;
			x=findfirst(s3,&full,0);
			while (!x)
				{
				strcpy(sp,s2);
				copyf(sp,s1,full.ff_name);
				x=findnext(&full);
				}
			}
		/*strcpy(s4,s2);
		strcat(s4,"\\*.");
		struct ffblk full1;
		x=findfirst(s4,&full1,0x10);
		if (x==0)
			{
			strcat(s1,"\\");
			strcat(s2,"\\");
			struct ffblk full1;
			x=findfirst(s4,&full1,0x10);
			while (!x)
				{
				strcpy(sp,s2);
				copyp(sp,s1,full1.ff_name);
				x=findnext(&full1);
				}
			}
		else return;  */
	}
Beispiel #7
0
/*
 * Generate the synthetic signal.
 * At the beginning of an erasure determine the pitch, and extract
 * one pitch period from the tail of the signal. Do an OLA for 1/4
 * of the pitch to smooth the signal. Then repeat the extracted signal
 * for the length of the erasure. If the erasure continues for more than
 * 10 ms, increase the number of periods in the pitchbuffer. At the end
 * of an erasure, do an OLA with the start of the first good frame.
 * The gain decays as the erasure gets longer.
 */
void LowcFE::dofe(short *out)
{
    pitchbufend = &pitchbuf[HISTORYLEN];

    if (erasecnt == 0) {
 	convertsf(history, pitchbuf, HISTORYLEN); /* get history */
	pitch = findpitch(); /* find pitch */
	poverlap = pitch >> 2; /* OLA 1/4 wavelength */
	/* save original last poverlap samples */
	copyf(pitchbufend - poverlap, lastq, poverlap);
	poffset = 0; /* create pitch buffer with 1 period */
	pitchblen = pitch;
	pitchbufstart = pitchbufend - pitchblen;
	overlapadd(lastq, pitchbufstart - poverlap,
		   pitchbufend - poverlap, poverlap);
	/* update last 1/4 wavelength in history buffer */
	convertfs(pitchbufend - poverlap, &history[HISTORYLEN-poverlap],
		  poverlap);
	getfespeech(out, FRAMESZ); /* get synthesized speech */
    } else if (erasecnt == 1 || erasecnt == 2) {
Beispiel #8
0
xaset_t *xaset_copy(pool *work_pool, xaset_t *set, size_t msize,
    XASET_MCOPY copyf) {
  xaset_t *newset;
  xasetmember_t *n,*p,**pos;

  if (!copyf && !msize) {
    errno = EINVAL;
    return NULL;
  }

  work_pool = (work_pool ? work_pool : set->pool);

  if (!(newset = xaset_create(work_pool, set->xas_compare)))
    return NULL;

  pos = &newset->xas_list;

  /* NOTE: xaset_insert_sort is not used here for performance
     reasons. */

  for (p = set->xas_list; p; p=p->next) {
    n = copyf ? copyf(p) : (xasetmember_t *) palloc(work_pool, msize);
    if (!n)
      return NULL;			/* Could clean up here */

    if (!copyf)
      memcpy(n, p, msize);

    /* Create links */
    n->prev = *pos;
    n->next = NULL;
    if (*pos)
      pos = &(*pos)->next;
    *pos = n;
  }

  return newset;
}
Beispiel #9
0
/*
 * Point packaging to the appropriate contents file. This is primarily used
 * to establish a dryrun contents file. If the malloc() doesn't work, this
 * returns 99 (internal error), else 0.
 */
int
set_cfdir(char *cfdir)
{
	char	realcf[PATH_MAX];
	char	tmpcf[PATH_MAX];
	int	status;

	if (cfdir == NULL) {
		pkgadm_dir = get_PKGADM();
		return (0);
	}

	if ((pkgadm_dir = strdup(cfdir)) == NULL) {
		return (99);
	}

	(void) snprintf(tmpcf, sizeof (tmpcf), "%s/contents", pkgadm_dir);

	/*
	 * return if a temporary contents file already exists -
	 * assume it is from a prior package in this series.
	 */

	if (access(tmpcf, F_OK) == 0) {
		return (0);
	}

	/*
	 * no temporary contents file exists - create one.
	 */

	(void) snprintf(realcf, sizeof (realcf), "%s/contents", get_PKGADM());

	/*
	 * If there's a contents file there already, copy it
	 * over, otherwise initialize one.  Make sure that the
	 * server, if running, flushes the contents file.
	 */

	(void) pkgsync(NULL, get_PKGADM(), B_FALSE);

	/* create new contents file if one does not already exist */

	if (access(realcf, F_OK) != 0) {
		int n;

		n = open(tmpcf, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL, 0644);
		if (n < 0) {
			progerr(gettext(ERR_CREAT_CONT), tmpcf,
			    strerror(errno));
			return (99);
		}
		(void) close(n);
	} else {

		/* contents file exists, save in pkgadm-dir */

		status = copyf(realcf, tmpcf, (time_t)0);
		if (status != 0) {
			progerr(gettext(ERR_DRCONTCP), tmpcf);
			return (99);
		}
	}

	return (0);
}
Beispiel #10
0
int main( int ac, char **av )
{
    if( ac < 3 || av[0][0] == '-' )
    {
        printf(
               "mkbulk: combine Phantom class files to a special\n"
               "bulk file to bundle with kernel (classes boot module)\n"
               "\n"
               "Usage: mkbulk outfile infile [...]\n"
              );
        exit(1);
    }

    ac--; av++;

    char *outfn = av[0];
    ac--;
    av++;


    outf = fopen( outfn, "wb" );
    if( outf == NULL )
    {
        printf("Can't open %s for write\n", outfn);
        exit(1);
    }

    //printf("Writing bulk to %s: ", outfn);


    while( ac-- )
    {
        const char *infn = *av++;

        const cns = 1024;
        char cn[cns];
        int fail = fn2cn( cn, infn, cns );

        if(fail) continue;

        FILE *inf = fopen( infn, "rb" );
        if( outf == NULL )
        {
            printf("can't open %s, skip%c ", infn, ac == 0 ? ' ' : ',');
            continue;
        }

        //printf("%s%c ", infn, ac == 0 ? ' ' : ',' );

        if( fseek( inf, 0, SEEK_END ) )
        {
            printf("can't seek %s, skip%c ", infn, ac == 0 ? ' ' : ',');
            fclose(inf);
            continue;
        }

        long size = ftell(inf);

        // TODO read class name from the class file!
        save_hdr( cn, size );
        copyf( outf, inf, (int)size );

        if(ferror(inf) || ferror(outf))
        {
            printf("I/O error\n");
            exit(2);
        }

        fclose( inf );
    }

    fclose(outf);
    //printf("done\n");
    return 0;
}
Beispiel #11
0
static void
outvol(struct cfent **eptlist, int eptnum, int part, int nparts)
{
	FILE	*fp;
	char	*svpt, *path, temp[PATH_MAX];
	int	i;


	if (nparts > 1)
		(void) fprintf(stderr, gettext(" -- part %2d:\n"), part);
	if (part == 1) {
		/* re-write pkgmap, but exclude local pathnames */
		(void) snprintf(temp, sizeof (temp), "%s/pkgmap", pkgloc);
		if ((fp = fopen(temp, "w")) == NULL) {
			progerr(gettext(ERR_TEMP), errno);
			quit(99);
		}
		(void) fprintf(fp, ": %d %ld\n", nparts, limit);
		for (i = 0; eptlist[i]; i++) {
			svpt = eptlist[i]->ainfo.local;
			if (!strchr("sl", eptlist[i]->ftype))
				eptlist[i]->ainfo.local = NULL;
			if (ppkgmap(eptlist[i], fp)) {
				progerr(gettext(ERR_TEMP), errno);
				quit(99);
			}
			eptlist[i]->ainfo.local = svpt;
		}
		(void) fclose(fp);
		(void) fprintf(stderr, "%s\n", temp);
	}

	(void) snprintf(temp, sizeof (temp), "%s/pkginfo", pkgloc);
	if (copyf(svept->ainfo.local, temp, svept->cinfo.modtime))
		quit(1);
	(void) fprintf(stderr, "%s\n", temp);

	for (i = 0; i < eptnum; i++) {
		if (eptlist[i]->volno != part)
			continue;
		if (strchr("dxslcbp", eptlist[i]->ftype))
			continue;
		if (eptlist[i]->ftype == 'i') {
			if (eptlist[i] == svept)
				continue; /* don't copy pkginfo file */
			(void) snprintf(temp, sizeof (temp),
				"%s/install/%s", pkgloc,
				eptlist[i]->path);
			path = temp;
		} else
			path = srcpath(pkgloc, eptlist[i]->path, part, nparts);
		if (sflag) {
			if (slinkf(eptlist[i]->ainfo.local, path))
				quit(1);
		} else if (copyf(eptlist[i]->ainfo.local, path,
				eptlist[i]->cinfo.modtime)) {
			quit(1);
		}

		/*
		 * If the package file attributes can be sync'd up with
		 * the pkgmap, we fix the attributes here.
		 */
		if (*(eptlist[i]->ainfo.owner) != '$' &&
		    *(eptlist[i]->ainfo.group) != '$' && getuid() == 0) {
			/* Clear dangerous bits. */
			eptlist[i]->ainfo.mode=
			    (eptlist[i]->ainfo.mode & S_IAMB);
			/*
			 * Make sure it can be read by the world and written
			 * by root.
			 */
			eptlist[i]->ainfo.mode |= 0644;
			if (!strchr("in", eptlist[i]->ftype)) {
				/* Set the safe attributes. */
				averify(1, &(eptlist[i]->ftype),
				    path, &(eptlist[i]->ainfo));
			}
		}

		(void) fprintf(stderr, "%s\n", path);
	}
}