示例#1
0
/**
 *
 * @param boot_dev
 * @param arm_m_type
 * @param atags
 * @return
 */
int notmain(uint32_t boot_dev, uint32_t arm_m_type, uint32_t atags)
{

#ifdef ENABLE_FRAMEBUFFER
	fb_init();
#else
	bcm2835_uart_begin();
#endif

    printf("Compiled on %s at %s\n\n", __DATE__, __TIME__);
    mem_info();
	cpu_info();
	printf("\n");
	printf("EMMC Clock rate (Hz): %ld\n", bcm2835_vc_get_clock_rate(BCM2835_VC_CLOCK_ID_EMMC));
	printf("UART Clock rate (Hz): %ld\n", bcm2835_vc_get_clock_rate(BCM2835_VC_CLOCK_ID_UART));
	printf("ARM  Clock rate (Hz): %ld\n", bcm2835_vc_get_clock_rate(BCM2835_VC_CLOCK_ID_ARM));
	printf("CORE Clock rate (Hz): %ld\n", bcm2835_vc_get_clock_rate(BCM2835_VC_CLOCK_ID_CORE));
	printf("\n");
	printf("Set UART Clock rate 4000000 Hz: %ld\n", bcm2835_vc_set_clock_rate(BCM2835_VC_CLOCK_ID_UART, 4000000));
	printf("UART Clock rate (Hz): %ld\n", bcm2835_vc_get_clock_rate(BCM2835_VC_CLOCK_ID_UART));
	printf("\n");

	uint8_t mac_address[6];
	bcm2835_vc_get_board_mac_address(mac_address);
	printf("MAC address : %.2X:%.2X:%.2X:%.2X:%.2X:%.2X\n", mac_address[0],mac_address[1],mac_address[2],mac_address[3],mac_address[4],mac_address[5]);

	printf("\nProgram ending...\n");

    return 0;
}
int main() {
    int i = 0;
    const char *err;

    while (1) {
        if (!mem_info(&err))
            fprintf(stderr, "Mem info failed: %s\n", err);

        if (!cpu_info(&err))
            fprintf(stderr, "CPU info failed: %s\n", err);

        if (!read_procs(&err))
            fprintf(stderr, "Process info failed: %s\n", err);

        printf("%d\n", i++);

        usleep(50000);
    }
}
示例#3
0
/*
=======================================
    主程序
=======================================
*/
int main (int argc, char *argv[])
{
    fbuf_t file;
    const ansi_t *root;

    /* 建立 CrHack 系统 */
    if (!set_app_type(CR_APP_CUI))
        return (QST_ERROR);

    /* 参数解析 [搜索根目录] */
    if (argc < 1) {
        printf("filehash [directory]\n");
        return (QST_ERROR);
    }

    /* 生成性能测试对象 */
    s_profile = timer_new();

    /* 生成输出文件 */
    file_deleteA("__hash__.old");
    file_renameA("__hash__.old", "__hash__.txt");
    file = file_buf_openA("__hash__.txt", CR_FO_WO);
    if (file == NULL) {
        printf("can't create output file\n");
        return (QST_ERROR);
    }

    /* 枚举所有文件 */
    if (argc == 1)
        root = "";
    else
        root = argv[1];
    s_rdata = NULL;
    mem_info(&s_total, &s_avail);
    s_total = (s_total * 618) / 1000;
    file_searchA(root, TRUE, FALSE, FALSE, "*.*", hasher, file);

    /* 释放内存 */
    file_buf_close(file);
    timer_del(s_profile);
    TRY_FREE(s_rdata);
    return (QST_OKAY);
}
示例#4
0
void setup() {
    Serial.begin(9600);

    // int *bad_news = (int *) malloc(4000);

    mem_info("********* THIS IS THE BEGINNING *********");
    randomSeed(analogRead(0));

    int16_t Test_len = 1024;
    int16_t Test[Test_len];

    Serial.print("In: ");
    for (int16_t i=0; i < Test_len; i++) {
        Test[i] = random(0, 100);
if ( 1 ) {
        Serial.print(Test[i]);
        Serial.print(" ");
}
        }
    Serial.println();

    merge_sort(Test, Test_len);
    
if ( 1 ) {
    Serial.print("Out: ");
    for (int16_t i=0; i < Test_len; i++) {
        if ( i < Test_len-1 && Test[i] > Test[i+1] ) {
            Serial.print("Out of order!!");
            }

        Serial.print(Test[i]);
        Serial.print(" ");
        }
    Serial.println();
}
    }
示例#5
0
void
edit_main_rep::show_meminfo () {
  mem_info ();
}
示例#6
0
// sort in place, i.e. A will be reordered
void merge_sort(int16_t *A, int16_t A_len) {
    indent_in();
    indent();
    Serial.print("Entering merge sort: array addr ");
    Serial.print( (int) A );
    Serial.print(" len ");
    Serial.println( A_len);
    mem_info("");

    assert_free_mem_ok(128, "merge_sort");

    if ( A_len < 2 ) {
        indent_out();
        return;
        }

    if ( A_len == 2 ) {
        if ( A[0] > A[1] ) {
            int temp = A[0];
            A[0] = A[1];
            A[1] = temp;
            }
        indent_out();
        return;
        }

    // split A in half, sort left, sort right, then merge
    // left half is:  A[0], ..., A[split_point-1]
    // right half is: A[split_point], ..., A[A_len-1]

    int split_point = A_len / 2;

    indent();
    Serial.println("Doing left sort");

    merge_sort(A, split_point);

    mem_info("After left sort");

    indent();
    Serial.println("Doing right sort");

    merge_sort(A+split_point, A_len-split_point);

    mem_info("After right sort");

    // don't need the merging arrat S until this point
    int *S = (int *) malloc( A_len * sizeof(int) );

    assert_malloc_ok(S, "Cannot get merge buffer");

    mem_info("Doing merge");

    merge(A, split_point, A+split_point, A_len-split_point, S);

    for (int i=0; i < A_len; i++) {
        A[i] = S[i];
        }

    // now we are done with it
    free(S);

    mem_info("After free");
    indent_out();
    }
示例#7
0
文件: save.c 项目: megabajt/poldek
int pdir_create(struct pkgdir *pkgdir, const char *pathname,
                unsigned flags)
{
    struct vfile     *vf = NULL;
    char             path[PATH_MAX], tmp[PATH_MAX];
    char             suffix[64] = "", difftoc_suffix[256] = "";
    const char       *orig_pathname;
    int              i, nerr = 0;
    struct pdir      *idx;
    unsigned         st_flags = 0;

#if 0                           /* XXX: disabled cause to pdir_pkgdir_uniq() usage */
    if ((pkgdir->flags & PKGDIR_DIFF) && (pkgdir->flags & PKGDIR_UNIQED) == 0) {
        n_assert((flags & PKGDIR_CREAT_NOUNIQ) == 0);
        pkgdir__uniq(pkgdir);
    }
#endif
    
    idx = pkgdir->mod_data;
    if (pkgdir->ts == 0) 
        pkgdir->ts = time(0);

    if (pathname == NULL) {
        if (pkgdir->flags & PKGDIR_DIFF)
            pathname = pkgdir->orig_idxpath;
        else
            pathname = pdir_localidxpath(pkgdir);
    }
    
    n_assert(pathname);
    orig_pathname = pathname;
    
    //if ((pkgdir->flags & (PKGDIR_DIFF | PKGDIR_PATCHED)) == 0)
    //    flags |= PKGDIR_CREAT_wMD;

    
    if (pkgdir->flags & PKGDIR_DIFF) {
        char tstr[32];
        char *dn, *bn;

        strftime(tstr, sizeof(tstr), "%Y.%m.%d-%H.%M.%S",
                 gmtime(&pkgdir->orig_ts));
        
        snprintf(suffix, sizeof(suffix), ".diff.%s", tstr);
        snprintf(difftoc_suffix, sizeof(difftoc_suffix), "%s",
                 pdir_difftoc_suffix);

        memcpy(tmp, pathname, sizeof(tmp));
        n_basedirnam(tmp, &dn, &bn);
        if (!util__mksubdir(dn, pdir_packages_incdir)) {
			nerr++;
            goto l_end;
        }
        
        snprintf(path, sizeof(path), "%s/%s/%s", dn, pdir_packages_incdir, bn);
        memcpy(tmp, path, sizeof(tmp));
        pathname = tmp;
    }


    if (mkidx_pathname(path, sizeof(path), pathname, suffix) == NULL) {
        nerr++;
		goto l_end;
    }

    msgn_tty(1, _("Writing %s..."), vf_url_slim_s(path, 0));
    msgn_f(1, _("Writing %s..."), path);
    

    do_unlink(path);
    if ((vf = vfile_open(path, VFT_TRURLIO, VFM_RW)) == NULL) {
		nerr++;
		goto l_end;
    }
    
    put_fheader(vf->vf_tnstream, pdir_poldeksindex, pkgdir);
    
    
    n_stream_printf(vf->vf_tnstream, "%%%s%lu\n", pdir_tag_ts, pkgdir->ts);
    n_stream_printf(vf->vf_tnstream, "%%%s\n", pdir_tag_endvarhdr);

    if (pkgdir->flags & PKGDIR_DIFF) {
        n_stream_printf(vf->vf_tnstream, "%%%s%lu\n", pdir_tag_ts_orig,
                        pkgdir->orig_ts);

        if (pkgdir->removed_pkgs) {
            n_stream_printf(vf->vf_tnstream, "%%%s", pdir_tag_removed);
            for (i=0; i < n_array_size(pkgdir->removed_pkgs); i++) {
                struct pkg *pkg = n_array_nth(pkgdir->removed_pkgs, i);
            
                n_stream_printf(vf->vf_tnstream, "%s-", pkg->name);
                if (pkg->epoch)
                    n_stream_printf(vf->vf_tnstream, "%d:", pkg->epoch);
                n_stream_printf(vf->vf_tnstream, "%s-%s ", pkg->ver, pkg->rel);
            }
            n_stream_printf(vf->vf_tnstream, "\n");
        }
    }

    if (pkgdir->depdirs && n_array_size(pkgdir->depdirs)) {
        n_stream_printf(vf->vf_tnstream, "%%%s", pdir_tag_depdirs);
        
        for (i=0; i<n_array_size(pkgdir->depdirs); i++) {
            n_stream_printf(vf->vf_tnstream, "%s%c",
                    (char*)n_array_nth(pkgdir->depdirs, i),
                    i + 1 == n_array_size(pkgdir->depdirs) ? '\n':':');
        }
    }

    if (pkgdir->pkgroups) {
        tn_buf *nbuf = n_buf_new(8192);
        
        n_stream_printf(vf->vf_tnstream, "%%%s\n", pdir_tag_pkgroups);
        pkgroup_idx_store(pkgdir->pkgroups, nbuf);
        n_stream_write(vf->vf_tnstream, n_buf_ptr(nbuf), n_buf_size(nbuf));
        n_stream_printf(vf->vf_tnstream, "\n");
        n_buf_free(nbuf);
    }
        
    n_stream_printf(vf->vf_tnstream, "%%%s\n", pdir_tag_endhdr);

    if (pkgdir->pkgs == NULL)
        goto l_close;

    if (flags & PKGDIR_CREAT_NODESC)
        st_flags |= PKGSTORE_NODESC;

    if (flags & PKGDIR_CREAT_v018x)
        st_flags |= PKGSTORE_NOTIMESTAMP;
    //flags |= PKGDIR_CREAT_PKG_Fv017;
    //n_array_sort(pkgdir->pkgs);
    n_array_isort_ex(pkgdir->pkgs, (tn_fn_cmp)pdir_pkg_cmp);
    for (i=0; i < n_array_size(pkgdir->pkgs); i++) {
        struct pkg *pkg = n_array_nth(pkgdir->pkgs, i);

        pdir_pkg_store(pkg, vf->vf_tnstream, pkgdir->depdirs, st_flags);
#if 0                           /* debug stuff */
        if (i % 200 == 0) {
            printf("%d. ", i);
            mem_info(-10, "i");
        }
#endif        
    }
    

 l_close:
	if (vf) {
		vfile_close(vf);
		vf = NULL;
	}
	
    /* update *.diff list   */
    if (pkgdir->flags & PKGDIR_DIFF) {
        char line[1024];
        int  line_len;
        
        line_len = n_snprintf(line, sizeof(line), "%s %lu %s %lu\n", 
                              n_basenam(path), pkgdir->ts,
                              idx->mdd_orig, pkgdir->orig_ts);
        
        if (!pdir_difftoc_update(pathname, difftoc_suffix, line, line_len)) {
            nerr++;
            goto l_end;
        }
    }
    
    i = pdir_digest_create(pkgdir, path, 0); // skip .md creation,
                                             // old, old poldek  

	if (!i)
		nerr++;
    
    if (pkgdir->flags & PKGDIR_DIFF)
        pdir_difftoc_vacuum(orig_pathname, pathname, difftoc_suffix);
	
 l_end:
    return nerr == 0;
}