コード例 #1
0
int main(int argc, char **argv)
{
	check_free();
	check_free2();
	check_alignment();
	check_allocation_near_chunk_size();
	check_leak_detection();
	check_object_growth();
        return 0;
}
コード例 #2
0
ファイル: serving_request.cpp プロジェクト: Cyaagain/thrill
ServingRequest::ServingRequest(
    const CompletionHandler& on_cmpl,
    const FileBasePtr& file,
    void* buffer, offset_type offset, size_type bytes,
    ReadOrWriteType type)
    : Request(on_cmpl, file, buffer, offset, bytes, type) {
#ifdef THRILL_CHECK_BLOCK_ALIGNING
    // Direct I/O requires file system block size alignment for file offsets,
    // memory buffer addresses, and transfer(buffer) size must be multiple
    // of the file system block size
    if (file->need_alignment())
        check_alignment();
#endif
}
コード例 #3
0
static int rk_load_data(struct rk_crypto_info *dev,
			struct scatterlist *sg_src,
			struct scatterlist *sg_dst)
{
	unsigned int count;

	dev->aligned = dev->aligned ?
		check_alignment(sg_src, sg_dst, dev->align_size) :
		dev->aligned;
	if (dev->aligned) {
		count = min(dev->left_bytes, sg_src->length);
		dev->left_bytes -= count;

		if (!dma_map_sg(dev->dev, sg_src, 1, DMA_TO_DEVICE)) {
			dev_err(dev->dev, "[%s:%d] dma_map_sg(src)  error\n",
				__func__, __LINE__);
			return -EINVAL;
		}
		dev->addr_in = sg_dma_address(sg_src);

		if (sg_dst) {
			if (!dma_map_sg(dev->dev, sg_dst, 1, DMA_FROM_DEVICE)) {
				dev_err(dev->dev,
					"[%s:%d] dma_map_sg(dst)  error\n",
					__func__, __LINE__);
				dma_unmap_sg(dev->dev, sg_src, 1,
					     DMA_TO_DEVICE);
				return -EINVAL;
			}
			dev->addr_out = sg_dma_address(sg_dst);
		}
	} else {
		count = (dev->left_bytes > PAGE_SIZE) ?
			PAGE_SIZE : dev->left_bytes;

		if (!sg_pcopy_to_buffer(dev->first, dev->nents,
					dev->addr_vir, count,
					dev->total - dev->left_bytes)) {
			dev_err(dev->dev, "[%s:%d] pcopy err\n",
				__func__, __LINE__);
			return -EINVAL;
		}
		dev->left_bytes -= count;
		sg_init_one(&dev->sg_tmp, dev->addr_vir, count);
		if (!dma_map_sg(dev->dev, &dev->sg_tmp, 1, DMA_TO_DEVICE)) {
			dev_err(dev->dev, "[%s:%d] dma_map_sg(sg_tmp)  error\n",
				__func__, __LINE__);
			return -ENOMEM;
		}
		dev->addr_in = sg_dma_address(&dev->sg_tmp);

		if (sg_dst) {
			if (!dma_map_sg(dev->dev, &dev->sg_tmp, 1,
					DMA_FROM_DEVICE)) {
				dev_err(dev->dev,
					"[%s:%d] dma_map_sg(sg_tmp)  error\n",
					__func__, __LINE__);
				dma_unmap_sg(dev->dev, &dev->sg_tmp, 1,
					     DMA_TO_DEVICE);
				return -ENOMEM;
			}
			dev->addr_out = sg_dma_address(&dev->sg_tmp);
		}
	}
	dev->count = count;
	return 0;
}
コード例 #4
0
ファイル: cpu32-check.c プロジェクト: osfreedom/bdm-osbdm
int
main(int argc, char **argv)
{
    char          *dev = NULL;
    int           arg;
    int           driver_debug = 0;
    int           delay_counter = 0;
    int           options_stop_on_error = 1;
    int           options_stop_quiet = 0;
    unsigned int  driver_version;
    int           cpu_type;
    int           iface;
    int           reg_check_loops = 1;
    int           align_check_loops = 1;
    int           external_mem_check_loops = 1;
    int           internal_mem_check_loops = 1;
    int           external_ram_execute_loops = 1;
    int           internal_ram_execute_loops = 1;

    if (argc <= 1) {
        usage();
    }

    for (arg = 1; arg < argc; arg++) {
        if (argv[arg][0] != '-') {
            if (dev) {
                printf(" Device name specified more than once");
                exit(1);
            }
            dev = argv[arg];
        }
        else {
            switch (argv[arg][1]) {
            case 'd':
                arg++;
                if (arg == argc) {
                    printf(" -d option requires a parameter");
                    exit(0);
                }
                driver_debug = strtoul(argv[arg], NULL, 0);
                break;

            case 'v':
                options_verbose = 1;
                break;

            case 'D':
                arg++;
                if (arg == argc) {
                    printf(" -D option requires a parameter");
                    exit(0);
                }
                delay_counter = strtoul(argv[arg], NULL, 0);
                break;

            case 'r':
                arg++;
                if (arg == argc) {
                    printf(" -r option requires a parameter");
                    exit(0);
                }
                reg_check_loops = strtoul(argv[arg], NULL, 0);
                break;

            case 'm':
                arg++;
                if (arg == argc) {
                    printf(" -m option requires a parameter");
                    exit(0);
                }
                internal_mem_check_loops = strtoul(argv[arg], NULL, 0);
                break;

            case 'M':
                arg++;
                if (arg == argc) {
                    printf(" -M option requires a parameter");
                    exit(0);
                }
                external_mem_check_loops = strtoul(argv[arg], NULL, 0);
                break;

            case 'e':
                arg++;
                if (arg == argc) {
                    printf(" -e option requires a parameter");
                    exit(0);
                }
                internal_ram_execute_loops = strtoul(argv[arg], NULL, 0);
                break;

            case 'E':
                arg++;
                if (arg == argc) {
                    printf(" -E option requires a parameter");
                    exit(0);
                }
                external_ram_execute_loops = strtoul(argv[arg], NULL, 0);
                break;

            case 'a':
                arg++;
                if (arg == argc) {
                    printf(" -a option requires a parameter");
                    exit(0);
                }
                align_check_loops = strtoul(argv[arg], NULL, 0);
                break;

            case 'C':
                options_stop_on_error = 0;
                break;

            case 'Q':
                options_stop_quiet = 1;
                break;

            default:
                printf(" Unknown option!");

            case '?':
            case 'h':
                usage();
                break;
            }
        }
    }

    if (!dev)
    {
        printf(" ERROR: No BDM device set.\n");
        exit(1);
    }

    if (bdmOpen(dev) < 0)
        show_error("Open");

    if (driver_debug)
        bdmSetDriverDebugFlag(driver_debug);

    if (delay_counter)
        bdmSetDelay(delay_counter);

    if (bdmGetDrvVersion(&driver_version) < 0)
        show_error("GetDrvVersion");

    printf("BDM Driver Version : %x.%x\n",
           driver_version >> 8, driver_version & 0xff);

    if (bdmGetProcessor(&cpu_type) < 0)
        show_error("GetProcessor");

    switch(cpu_type) {
    case BDM_CPU32:
        printf("Processor  : CPU32\n");
        break;
    default:
        printf("Unsupported processor type!\n");
        clean_exit(1);
        break;
    }

    if (bdmGetInterface(&iface) < 0)
        show_error("GetInterface");

    switch(iface) {
    case BDM_CPU32_ERIC:
        printf("Interface  : Eric's CPU32\n");
        break;
    case BDM_CPU32_ICD:
        printf("Interface  : ICD (P&E) CPU32\n");
        break;
    default:
        printf("Unknown or unsupported interface type!\n");
        clean_exit(1);
        break;
    }

    stop_on_error = options_stop_on_error;
    stop_quiet = options_stop_quiet;

    if (reg_check_loops)
        check_registers(reg_check_loops);

    if (internal_mem_check_loops)
        verify_internal_mem(internal_mem_check_loops);

    /*
     * Only test the whole memory in the address test; the others take too long.
     */
    if (external_mem_check_loops)
        verify_external_mem(external_mem_check_loops, EXTERNAL_MEM_SIZE, 0x400);

    if (align_check_loops)
        check_alignment(align_check_loops);

    if (internal_ram_execute_loops)
        execute(INTERNAL_RAM, internal_ram_execute_loops);

    if (external_ram_execute_loops)
        execute(EXTERNAL_RAM, external_ram_execute_loops);

    clean_exit(0);
    return 0;
}
コード例 #5
0
int bench_main(int argc, char *argv[])
{
     double tmin = 0.0;
     double tol;
     int repeat = 0;
     int rounds = 10;
     int iarounds = 0;
     int arounds = 1; /* this is too low for precise results */
     int c;
     int index;
     char *short_options = make_short_options(long_options);

     check_alignment(&tol);

     report = report_verbose; /* default */
     verbose = 0;

     tol = SINGLE_PRECISION ? 1.0e-3 : 1.0e-10;
     bench_srand(1);

     while ((c = getopt_long (argc, argv, short_options,
			      long_options, &index)) != -1) {
	  switch (c) {
	      case 't' :
		   tmin = strtod(optarg, 0);
		   break;
	      case 'r':
		   repeat = atoi(optarg);
		   break;
	      case 's':
		   timer_init(tmin, repeat);
		   speed(optarg);
		   break;
	      case 'd':
		   report_can_do(optarg);
		   break;
	      case 'o':
		   useropt(optarg);
		   break;
	      case 'v':
		   if (optarg)
			verbose = atoi(optarg);
		   else
			++verbose;
		   break;
	      case 'y':
		   verify(optarg, rounds, tol);
		   break;
	      case 'a':
		   accuracy(optarg, arounds, iarounds);
		   break;
	      case 'i':
		   report_info(optarg);
		   break;
	      case 'I':
		   report_info_all();
		   break;
	      case 'h':
		   usage(argv[0], long_options);
		   break;

	      case 300: /* --report-mflops */
		   report = report_mflops;
		   break;

	      case 310: /* --report-time */
		   report = report_time;
		   break;

 	      case 320: /* --report-benchmark */
		   report = report_benchmark;
		   break;

 	      case 330: /* --report-verbose */
		   report = report_verbose;
		   break;

	      case 400: /* --print-time-min */
		   timer_init(tmin, repeat);
		   ovtpvt("%g\n", time_min);
		   break;

	      case 401: /* --verify-rounds */
		   rounds = atoi(optarg);
		   break;

	      case 402: /* --print-precision */
		   if (SINGLE_PRECISION)
			ovtpvt("single\n");
		   else if (LDOUBLE_PRECISION)
			ovtpvt("long-double\n");
		   else if (DOUBLE_PRECISION)
			ovtpvt("double\n");
		   else 
			ovtpvt("unknown %d\n", sizeof(bench_real));
		   break;

	      case 403: /* --verify-tolerance */
		   tol = strtod(optarg, 0);
		   break;

	      case 404: /* --random-seed */
		   bench_srand(atoi(optarg));
		   break;

	      case 405: /* --accuracy-rounds */
		   arounds = atoi(optarg);
		   break;
		   
	      case 406: /* --impulse-accuracy-rounds */
		   iarounds = atoi(optarg);
		   break;
		   
	      case '?':
		   /* `getopt_long' already printed an error message. */
		   break;

	      default:
		   abort ();
	  }
     }

     /* assume that any remaining arguments are problems to be
        benchmarked */
     while (optind < argc) {
	  timer_init(tmin, repeat);
	  speed(argv[optind++]);
     }

     cleanup();
     bench_free(short_options);
     return 0;
}
コード例 #6
0
ファイル: _turn.c プロジェクト: ehershey/pd
int cmd_turn(string str) {
    string whom;
    object *inv;
    object tp, ob;
    int which, skip, i, faith, wisdom;

   if (!spell()) {
      notify_fail("What?\n");
      return 0;
   }
    this_player()->set_magic_round();
    if(!str) {
        notify_fail("Turn what?\n");
        return 0;
    }
    tp = this_player();
    if((string)tp->query_subclass() != "cleric") {
        notify_fail("You appear puzzled.\n");
        return 0;
    }
    if(environment(tp)->query_property("no magic")) {
        notify_fail("Something is blocking your concentration.\n");
        return 0;
    }
    if(tp->query_casting()) return 1;
    if(!check_alignment(tp, (string)tp->query_class())) {
        notify_fail("You have betrayed the source of your powers!\n");
        return 0;
    }
    ob = present(str, environment(tp));
    if(!ob) {
        if(str == "all") return turn_all(tp);
        inv = all_inventory(environment(tp));
        sscanf(str, "%s %d", whom, which);
        for(i=0, skip =0; i<sizeof(inv) && !ob; i++) {
            if(inv[i]->id(whom)) {
                skip ++;
                if(skip == which) ob = inv[i];
            }
        }
        if(!ob) {
            notify_fail("Turn what?\n");
            return 0;
        }
    }
    faith = (int)tp->query_skill("belief");
    wisdom = (int)ob->query_stats("wisdom")*3/4;
    faith -= wisdom;
    if(faith < 2) faith = 2;
    faith = random(faith);
    if((int)tp->query_mp() < faith) {
        notify_fail("Too low on magic power.\n");
        return 0;
    }
    if((string)ob->query("race") != "undead" && (string)ob->query("race") != "lich" && (string)ob->query("race") != "vampire") {
        notify_fail(ob->query_cap_name()+" is not undead!\n");
        return 0;
    }
    tp->add_mp(-faith);
    if(!this_player()->kill_ob(ob)) {
        write(ob->query_cap_name()+" can't be attacked by you yet.");
       return 1;
    }
    say(tp->query_cap_name()+" mutters a prayer to turn the undead.\n", tp);
    if(faith > 65) {
        write("The undead being turns to dust.\n");
        say(ob->query_cap_name()+" turns to dust in response to "+tp->query_cap_name()+"'s prayer.\n", tp);
        ob->remove();
        tp->add_alignment(15);
        tp->add_skill_points("belief", 100);
    }
    else {
        tp->set_casting(faith);
        write("The undead writhes in response to your holy prayer.\n");
        say(ob->query_cap_name()+" writhes in response to "+tp->query_cap_name()+"'s prayer.\n", tp);
        tp->add_skill_points("faith", faith);
    }
    return 1;
}