int main (void) { puts("in main"); myfun(); puts("after myfunc()"); return 0; }
int main() { char name[30]; Mystruct ms2; ms2 = myfun(); printf("val1: %d val2: %d",ms2.a,ms2.b); return 0; }
// user function inline void poisson_kernel_populate(const int *dispx, const int *dispy, const int *idx, double *u, double *f, double *ref) { double x = dx * (double)(idx[0] + dispx[0]); double y = dy * (double)(idx[1] + dispy[0]); u[OPS_ACC3(0, 0)] = myfun(sin(M_PI * x), cos(2.0 * M_PI * y)) - 1.0; f[OPS_ACC4(0, 0)] = -5.0 * M_PI * M_PI * sin(M_PI * x) * cos(2.0 * M_PI * y); ref[OPS_ACC5(0, 0)] = sin(M_PI * x) * cos(2.0 * M_PI * y); }
void test_scalar(){ std::cout << "== test_scalar() ==" << std::endl; // use with normal floats double a,b; a = 0.3; b = 0.5; double c = myfun(a,b); std::cout << "Result: " << c << std::endl; // use with AutoDiffScalar typedef Eigen::AutoDiffScalar<Eigen::VectorXd> AScalar; AScalar Aa,Ab; Aa.value() = 0.3; Ab.value() = 0.5; Aa.derivatives() = Eigen::VectorXd::Unit(2,0); Ab.derivatives() = Eigen::VectorXd::Unit(2,1); AScalar Ac = myfun(Aa,Ab); std::cout << "Result: " << Ac.value() << std::endl; std::cout << "Gradient: " << Ac.derivatives().transpose() << std::endl; }
int main(void) { char *str; str = myfun(); printf("main first: %s\n", str); printf("main second: "); printf("%s\n", str); return 0; }
int main() { intptr_t here0 = 0; intptr_t here1 = 0; const char *str = "Hello World!"; size_t len = strlen(str); here0 = (intptr_t)syscall(SYS_brk, 0); here1 = (intptr_t)syscall(SYS_brk, here0 + len + 1); printf("Starting dummy 0x"LX" 0x"LX"\n", here0, here1); memcpy((void *)here0, str, len + 1); printf("String: %s\n", (const char *)here0); syscall(SYS_brk, here0); while (1) { struct timeval tv = { 0 }; sleep(2); gettimeofday(&tv, NULL); printf("Working "LU"."LU"\n", (size_t)tv.tv_sec, (size_t)tv.tv_usec); myfun(); } printf("Stopping dummy\n"); return 0; }
void punyopt ( int argc, char *argv[], bool (*myfun)(int c), char *myoptions) { char *options; int c; pr_cmd_line(argc, argv); if (myoptions) { options = emalloc(strlen(myoptions) + strlen(Default) + 1); cat(options, myoptions, Default, NULL); } else { options = strdup(Default); } setprogname(argv[0]); setlocale(LC_NUMERIC, "en_US"); while ((c = getopt(argc, argv, options)) != -1) { if (myfun && myfun(c)) continue; switch (c) { case 'h': case '?': usage(); break; case 'c': Option.cleanup = FALSE; break; case 'd': Option.dir = optarg; break; case 'e': Option.dest = optarg; break; case 'f': Option.file = optarg; break; case 'i': Option.iterations = strtoll(optarg, NULL, 0); break; case 'l': Option.loops = strtoll(optarg, NULL, 0); if (Option.loops == 0) { Option.loops = LLONG_MAX; } break; case 'n': Option.name_size = strtoll(optarg, NULL, 0); break; case 'p': Option.print = TRUE; break; case 'r': Option.results = optarg; break; case 's': Option.sleep_secs = strtoll(optarg, NULL, 0); break; case 't': Option.numthreads = strtoll(optarg, NULL, 0); break; case 'v': Option.value = optarg; break; case 'x': Option.xattr = optarg; break; case 'z': Option.file_size = strtoll(optarg, NULL, 0); break; default: usage(); break; } } free(options); }
void prog1() { cout << myfun(10) << endl; cout << myfun(5.4) << endl; }