static void func1(int x) { BEGIN_LAGS() std::cout << __FUNCTION__ << ":" << __LINE__ << std::endl; if(x > 0) { std::this_thread::sleep_for(std::chrono::seconds(2)); } std::this_thread::sleep_for(std::chrono::seconds(2)); int cnt = 100; double sum = 0; func0(100, 0); func0(30, -1); END_LAGS() }
size_t NC_STACK_bitmap::compatcall(int method_id, void *data) { switch( method_id ) { case 0: return (size_t)func0( (stack_vals *)data ); case 1: return (size_t)func1( (stack_vals *)data ); case 2: return func2( (stack_vals *)data ); case 3: return func3( (stack_vals *)data ); case 64: return (size_t)rsrc_func64( (stack_vals *)data ); case 65: return rsrc_func65( (rsrc **)data ); case 128: return (size_t)bitmap_func128( (stack_vals *)data ); case 129: return (size_t)bitmap_func129( (stack_vals *)data ); case 130: bitmap_func130( (bitmap_arg130 *)data ); return 1; default: break; } return NC_STACK_rsrc::compatcall(method_id, data); }
void bar (int i) { switch (i) { default: func0 (); break; case 1: func1 (); break; case 2: func2 (); break; case 3: func3 (); break; case 4: func4 (); break; case 5: func5 (); break; } }
int main() { boost::shared_ptr<const MyStruct> q = boost::make_shared<const MyStruct>(100); put(q); std::function<void (int)> fn = [](int x) {std::cout << "x = " << x << std::endl;}; mmm(12345, fn); int *p = nullptr; foo(p); const int* p2 = nullptr; foo(p2); int n = 100; foo(n); int& n1 = n; foo(n1); const int& n2 = n1; foo(n2); int a = 10; const int b = 20; funcA(a); funcA(b); funcB(a); funcB(b); func0(a); //func0(b); func1(a); func1(b); std::cout << "\n------------- mmmm2 -------------\n"; int x = 100; mmmm2(x); int *px = &x; mmmm2(px); const int* px2 = &x; mmmm2(px2); return 0; }
static double func0_4(const double x[], const int iResponse) { if (iResponse == 0) return func0(x, iResponse); else if (iResponse == 1) return func4(x, iResponse); else error("bad iResponse"); return 0; }
func1 (void) { Q a, b; a = q1 * q2; b = q3 * q4; w1 = a; w2 = b; func0 (); w3 = a; w4 = b; }
int main() { int a = 4, b = 5; int (*funcptr)(int, int) = func0; int c = func0(a, b); printf("%s: c = %d\n", __FUNCTION__, c); printf("funcptr's name = %s\n", addr_to_name((unsigned long)funcptr)); return 0; }
int func0(void) { if (1) { func0(); return (1); } else if (2) { func0(); return (2); } else { func0(); return (0); } while (1) { func0(); return (1); } for (; 1;) { func0(); return (1); } do { func0(); return (1); } while (1); }
void test_nested_implicit_cast_expr() { int func0(void*, void*); int func1(int, void*, void*); (double)func1(0, 0, 0); // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: use nullptr // CHECK-MESSAGES: :[[@LINE-2]]:23: warning: use nullptr // CHECK-FIXES: (double)func1(0, nullptr, nullptr); (double)func1(func0(0, 0), 0, 0); // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: use nullptr // CHECK-MESSAGES: :[[@LINE-2]]:26: warning: use nullptr // CHECK-MESSAGES: :[[@LINE-3]]:30: warning: use nullptr // CHECK-MESSAGES: :[[@LINE-4]]:33: warning: use nullptr // CHECK-FIXES: (double)func1(func0(nullptr, nullptr), nullptr, nullptr); }
void main(void) { /* INITIALIZE SERIAL INTERFACE TO 2400 BAUD @12MHz */ SCON = 0x52; /* SCON */ TMOD = 0x20; /* TMOD */ TCON = 0x69; /* TCON */ TH1 = 0xf3; /* TH1 */ printf("MAIN PROGRAM CALLS A FUNCTION IN BANK 0 \n"); func0(); printf("MAIN PROGRAM CALLS A FUNCTION IN BANK 1 \n"); func1(); while(1); }
int main () { int i[10], r; i[0] = 0; r = func0(0); if (i[0]) link_error0(); i[1] = 0; r = func1(0); if (i[1]) link_error1(); i[2] = 0; r = func2(0); if (i[2]) link_error2(); i[3] = 0; r = func3(0); if (i[3]) link_error3(); i[4] = 0; r = func4(0); if (i[4]) link_error4(); i[5] = 0; r = func5(0); if (i[5]) link_error5(); i[6] = 0; r = func6(0); if (i[6]) link_error6(); i[7] = 0; r = func7(0); if (i[7]) link_error7(); return r; }
int main() { int tmp = setjmp(jump_buffer); printf("tmp = %d\n", tmp); if (tmp == 0) { printf("first calling set_jmp\n"); func1(); } else if (tmp == 1) { printf("second calling set_jmp\n"); func2(); } else { printf("third calling set_jmp\n"); func0(); } return 0; }
namespace CPP14LanguageFeatures { // Function return type deduction. // // * This feature allows the use of the keyword `auto` // in place of a function's return type. // // * You can qualify the `auto` keyword with `const`, // `*`, `&`, etc... // // * It follows the same rules as `auto` variable // type deduction. // auto func0() { return 0; } static_assert(std::is_same<decltype(func0()), int>(), ""); auto func1() { std::string test{"hello!"}; return test; } static_assert(std::is_same<decltype(func1()), std::string>(), ""); const auto& func2() { static std::string test{"hello again!"}; return test; } static_assert(std::is_same<decltype(func2()), const std::string&>(), ""); // Here are some additional examples: template<typename T> struct SomeContainerWrapper { std::vector<const T*> vec; typename std::vector<const T*>::iterator beginCPP03() const { return std::begin(vec); } auto beginCPP11() const -> decltype(std::begin(vec)) { return std::begin(vec); } auto beginCPP14() const { return std::begin(vec); } }; template<typename T1, typename T2, typename T3> auto complicatedFuncCPP11(T1 x, T2 y, T3 z) -> decltype((x * y) - (y * z)) { return (x * y) - (y * z); } template<typename T1, typename T2, typename T3> auto complicatedFuncCPP14(T1 x, T2 y, T3 z) { return (x * y) - (y * z); } }
/* GCC should automatically detect attributes for these functions. At -O3 They'll be inlined, but that's ok. */ static int func2 (int a) { return i + a; } /* pure */ static int func3 (int a) { return a * 3; } /* const */ static int func4 (int a) { return func0(a) + a; } /* pure */
size_t NC_STACK_windp::compatcall(int method_id, void *data) { switch( method_id ) { case 0: return (size_t)func0( (stack_vals *)data ); case 1: return (size_t)func1( (stack_vals *)data ); case 3: func3( (stack_vals *)data ); return 1; case 64: return (size_t)windp_func64( (stack_vals *)data ); case 65: return (size_t)windp_func65( (windp_getNameMsg *)data ); case 66: return (size_t)windp_func66( (const char *)data ); case 67: return (size_t)windp_func67( (stack_vals *)data ); case 68: return (size_t)windp_func68( (stack_vals *)data ); case 69: return (size_t)windp_func69( (windp_getNameMsg *)data ); case 70: return (size_t)windp_func70( (stack_vals *)data ); case 71: return (size_t)windp_func71( (windp_openSessionMsg *)data ); case 72: return (size_t)windp_func72( (stack_vals *)data ); case 73: return (size_t)windp_func73( (stack_vals *)data ); case 74: return (size_t)windp_func74( (stack_vals *)data ); case 75: return (size_t)windp_func75( (const char *)data ); case 76: return (size_t)windp_func76( (windp_createPlayerMsg *)data ); case 77: return (size_t)windp_func77( (const char *)data ); case 78: return (size_t)windp_func78( (stack_vals *)data ); case 79: return (size_t)windp_func79( (windp_arg79 *)data ); case 80: return (size_t)windp_func80( (stack_vals *)data ); case 81: return (size_t)windp_func81( (stack_vals *)data ); case 82: return (size_t)windp_func82( (windp_arg82 *)data ); case 83: return (size_t)windp_func83( (stack_vals *)data ); case 84: return (size_t)windp_func84( (int *)data ); case 85: return (size_t)windp_func85( (stack_vals *)data ); case 86: return (size_t)windp_func86( (stack_vals *)data ); case 87: return (size_t)windp_func87( (windp_arg87 *)data ); case 88: return (size_t)windp_func88( (stack_vals *)data ); case 89: return (size_t)windp_func89( (const char **)data ); case 90: return (size_t)windp_func90( (stack_vals *)data ); case 91: return (size_t)windp_func91( (int *)data ); default: break; } return NC_STACK_network::compatcall(method_id, data); }
void filter(int *array, int X, int Y, int Z, int * seed, int N, FILE *ofp){ long long func_start = get_time(); double xr = round(Y/2.0); double yr = round(X/2.0); int radius = 5; int diameter = radius*2-1; int *radiusMatrix = (int *)malloc(diameter*diameter*sizeof(int)); fillMatrix(radiusMatrix, radius); int Ones = 0; int x, y; for(x = 0; x < diameter; x++){ for(y = 0; y < diameter; y++){ if(radiusMatrix[x*diameter + y] == 1) Ones++; } } double * objxy = (double *)malloc(Ones*2*sizeof(double)); getNeighbors(radiusMatrix, Ones, objxy, radius); double *weights = (double *)malloc(sizeof(double)*N); double *arrayX = (double *)malloc(sizeof(double)*N); double *arrayY = (double *)malloc(sizeof(double)*N); func0(weights, arrayX, arrayY, xr, yr, N); double * probability = (double *)malloc(sizeof(double)*N); double * x_j = (double *)malloc(sizeof(double)*N); double * y_j = (double *)malloc(sizeof(double)*N); double * cfd = (double *)malloc(sizeof(double)*N); double * u = (double *)malloc(sizeof(double)*N); int * index = (int*)malloc(sizeof(int)*Ones*N); int i, j; for(i = 1; i < Z; i++) { func1(seed, array, arrayX, arrayY, probability, objxy, index, Ones, i, X, Y, Z, N); func2(weights, probability, N); double x_e = 0; double y_e = 0; func3(arrayX, arrayY, weights, &x_e, &y_e, N); fprintf(ofp, "%f\n", x_e); fprintf(ofp, "%f\n", y_e); cfd[0] = weights[0]; for(j = 1; j < N; j++){ cfd[j] = weights[j] + cfd[j-1]; } double u1 = (1/((double)(N)))*rand1(seed, 0); func4(u, u1, N); func5(x_j, y_j, arrayX, arrayY, weights, cfd, u, N); } long long func_end = get_time(); printf("FUNC TIME : %f\n", elapsed_time(func_start, func_end)); //fflush(); for(i=0; i<Ones*2; i++) { fprintf(ofp, "%f\n", objxy[i]); } for(i=0; i<N; i++) { fprintf(ofp, "%f %f %f %f %f %f %f %f\n", weights[i], arrayX[i], arrayY[i], probability[i], x_j[i], y_j[i], cfd[i], u[i]); } for(i=0; i<Ones*N; i++) { fprintf(ofp, "%d\n", index[i]); } free(radiusMatrix); free(objxy); free(weights); free(probability); free(x_j); free(y_j); free(arrayX); free(arrayY); free(cfd); free(u); free(index); }
int main() { func0(); return 0; }