int test_three() { int retvalue; mode = 1; count = 0; if ((retvalue = signal1("reply", 1)) != 0) { printf("Test 3,0 failed return value %d\n", retvalue); return 1; } if ((retvalue = signal2("reply", 1, 2)) != 0) { printf("Test 3,1 failed return value %d\n", retvalue); return 1; } if ((retvalue = signal3("reply", 1, 2, 3)) != 0) { printf("Test 3,2 failed return value %d\n", retvalue); return 1; } if ((retvalue = data("reply", data_str, SIZEOF_DATA + 1)) != 0) { printf("Test 3,3 failed return value %d\n", retvalue); return 1; } sleep(1); if (count == 4) { printf("Test 3 OK\n"); return 0; } else { printf("Test 3 failed %d\n", count); return 1; } }
void QObjectBenchmark::signal_slot_benchmark() { QFETCH(int, type); Object singleObject; Object multiObject; Functor functor; singleObject.setObjectName("single"); multiObject.setObjectName("multi"); if (type == 5) { QObject::connect(&singleObject, &Object::signal0, functor); } else if (type == 4) { QObject::connect(&singleObject, &Object::signal0, &singleObject, &Object::slot0); } else { singleObject.connect(&singleObject, SIGNAL(signal0()), SLOT(slot0())); } multiObject.connect(&multiObject, SIGNAL(signal0()), SLOT(slot0())); // multiObject.connect(&multiObject, SIGNAL(signal0()), SLOT(signal1())); multiObject.connect(&multiObject, SIGNAL(signal1()), SLOT(slot1())); // multiObject.connect(&multiObject, SIGNAL(signal0()), SLOT(signal2())); multiObject.connect(&multiObject, SIGNAL(signal2()), SLOT(slot2())); // multiObject.connect(&multiObject, SIGNAL(signal0()), SLOT(signal3())); multiObject.connect(&multiObject, SIGNAL(signal3()), SLOT(slot3())); // multiObject.connect(&multiObject, SIGNAL(signal0()), SLOT(signal4())); multiObject.connect(&multiObject, SIGNAL(signal4()), SLOT(slot4())); // multiObject.connect(&multiObject, SIGNAL(signal0()), SLOT(signal5())); multiObject.connect(&multiObject, SIGNAL(signal5()), SLOT(slot5())); // multiObject.connect(&multiObject, SIGNAL(signal0()), SLOT(signal6())); multiObject.connect(&multiObject, SIGNAL(signal6()), SLOT(slot6())); // multiObject.connect(&multiObject, SIGNAL(signal0()), SLOT(signal7())); multiObject.connect(&multiObject, SIGNAL(signal7()), SLOT(slot7())); // multiObject.connect(&multiObject, SIGNAL(signal0()), SLOT(signal8())); multiObject.connect(&multiObject, SIGNAL(signal8()), SLOT(slot8())); // multiObject.connect(&multiObject, SIGNAL(signal0()), SLOT(signal9())); multiObject.connect(&multiObject, SIGNAL(signal9()), SLOT(slot9())); if (type == 0) { QBENCHMARK { singleObject.slot0(); } } else if (type == 1) {
int test_five(int amount) { int retvalue, i; mode = 3; count = 0; for (i = 0; i < amount; i++) { if ((retvalue = signal1("reply", 3)) != 0) { printf("Test 5,0 failed return value %d\n", retvalue); return 1; } } sleep(1); /* give time for reply to empty the queue */ for (i = 0; i < amount; i++) { if ((retvalue = signal2("reply", 3, 4)) != 0) { printf("Test 5,1 failed return value %d\n", retvalue); return 1; } } sleep(1); /* give time for reply to empty the queue */ for (i = 0; i < amount; i++) { if ((retvalue = signal3("reply", 3, 4, 65534)) != 0) { printf("Test 5,2 failed return value %d\n", retvalue); return 1; } } sleep(1); /* give time for reply to empty the queue */ for (i = 0; i < amount; i++) { if ((retvalue = data("reply", data_str, SIZEOF_DATA + 1)) != 0) { printf("Test 5,3 failed return value %d\n", retvalue); return 1; } } sleep(1); /* give time for reply to empty the queue */ if (count == (4 * amount)) { printf("Test 5 OK\n"); return 0; } else { printf("Test 5 failed, received %d out of %d\n", count, (4 * amount)); return 1; } }
void QObjectBenchmark::signal_slot_benchmark() { QFETCH(int, type); Object singleObject; Object multiObject; singleObject.setObjectName(QLatin1String("single")); multiObject.setObjectName(QLatin1String("multi")); singleObject.connect(&singleObject, SIGNAL(signal0()), SLOT(slot0())); multiObject.connect(&multiObject, SIGNAL(signal0()), SLOT(slot0())); // multiObject.connect(&multiObject, SIGNAL(signal0()), SLOT(signal1())); multiObject.connect(&multiObject, SIGNAL(signal1()), SLOT(slot1())); // multiObject.connect(&multiObject, SIGNAL(signal0()), SLOT(signal2())); multiObject.connect(&multiObject, SIGNAL(signal2()), SLOT(slot2())); // multiObject.connect(&multiObject, SIGNAL(signal0()), SLOT(signal3())); multiObject.connect(&multiObject, SIGNAL(signal3()), SLOT(slot3())); // multiObject.connect(&multiObject, SIGNAL(signal0()), SLOT(signal4())); multiObject.connect(&multiObject, SIGNAL(signal4()), SLOT(slot4())); // multiObject.connect(&multiObject, SIGNAL(signal0()), SLOT(signal5())); multiObject.connect(&multiObject, SIGNAL(signal5()), SLOT(slot5())); // multiObject.connect(&multiObject, SIGNAL(signal0()), SLOT(signal6())); multiObject.connect(&multiObject, SIGNAL(signal6()), SLOT(slot6())); // multiObject.connect(&multiObject, SIGNAL(signal0()), SLOT(signal7())); multiObject.connect(&multiObject, SIGNAL(signal7()), SLOT(slot7())); // multiObject.connect(&multiObject, SIGNAL(signal0()), SLOT(signal8())); multiObject.connect(&multiObject, SIGNAL(signal8()), SLOT(slot8())); // multiObject.connect(&multiObject, SIGNAL(signal0()), SLOT(signal9())); multiObject.connect(&multiObject, SIGNAL(signal9()), SLOT(slot9())); if (type == 0) { QBENCHMARK { singleObject.slot0(); } } else if (type == 1) {
int test_four() { int retvalue; mode = 2; count = 0; if ((retvalue = signal1("replyer", 1)) != 1) { printf("Test 4,0 failed return value %d\n", retvalue); return 1; } if ((retvalue = signal2("replyer", 1, 2)) != 1) { printf("Test 2,1 failed return value %d\n", retvalue); return 1; } if ((retvalue = signal3("replyer", 1, 2, 3)) != 1) { printf("Test 2,2 failed return value %d\n", retvalue); return 1; } if ((retvalue = data("replyer", data_str, SIZEOF_DATA)) != 1) { printf("Test 2,3 failed return value %d\n", retvalue); return 1; } printf("Test 4 OK\n"); return 0; }
int test_one() { int retvalue; mode = 0; count = 0; if ((retvalue = signal1("reply", 1)) != 2) { printf("Test 1,0 failed return value %d\n", retvalue); return 1; } if ((retvalue = signal2("reply", 1, 2)) != 2) { printf("Test 1,1 failed return value %d\n", retvalue); return 1; } if ((retvalue = signal3("reply", 1, 2, 3)) != 2) { printf("Test 1,2 failed return value %d\n", retvalue); return 1; } if ((retvalue = data("reply", data_str, SIZEOF_DATA)) != 2) { printf("Test 1,3 failed return value %d\n", retvalue); return 1; } printf("Test 1 OK\n"); return 0; }
void fly_init (int x0, int y0, int rows, int cols, char *font) { struct winsize ws; char *p; setup_termcap (); clipboard_text = NULL; // we need unbuffered input for select() to work fflush (stdin); setvbuf (stdin, NULL, _IONBF, 0); // ignore some signals, process some others signal (SIGHUP, SIG_IGN); signal (SIGINT, sig_interrupt); signal2 (SIGWINCH, sig_winch); #ifndef __bsdi__ signal2 (SIGTSTP, sig_stopped); signal2 (SIGCONT, sig_resumed); #endif if (fl_opt.platform == PLATFORM_BEOS_TERM) signal (SIGTSTP, SIG_IGN); // get terminal mode and save it tcgetattr (STDIN_FD, &tio); saved_tio = tio; // set terminal parameters /* stty sane - input: -ignbrk brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff -iuclc -ixany imaxbel */ tio.c_iflag &= ~ISTRIP; tio.c_iflag &= ~(ISTRIP|ICRNL|INLCR|IGNCR); /* stty sane - output: opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0 */ tio.c_oflag &= ~(ONLCR); /* stty sane - control: -parenb -parodd cs8 hupcl -cstopb cread -clocal -crtscts */ tio.c_cflag &= ~(CSIZE | HUPCL); tio.c_cflag |= CS8; /* stty sane - local: isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke */ //tio.c_lflag &= ~ISIG; tio.c_lflag &= ~(ICANON | ECHO | ECHOCTL); tio.c_cc[VMIN] = 1; tio.c_cc[VTIME] = 0; tio.c_cc[VQUIT] = _POSIX_VDISABLE; tio.c_cc[VDSUSP] = _POSIX_VDISABLE; tio.c_cc[VSTART] = _POSIX_VDISABLE; tio.c_cc[VSTOP] = _POSIX_VDISABLE; tcsetattr (STDIN_FD, TCSADRAIN, &tio); /* determine terminal dimensions */ rows = 0; cols = 0; if (ioctl (STDIN_FD, TIOCGWINSZ, &ws) == 0) { rows = ws.ws_row; cols = ws.ws_col; } else { p = getenv ("LINES"); if (p != NULL) rows = atoi (p); p = getenv ("COLUMNS"); if (p != NULL) cols = atoi (p); } // fallback values if (rows == 0 || cols == 0) { fprintf (stderr, "warning: cannot determine terminal window dimensions; " "assuming 80 x 24\n"); rows = 24; cols = 80; } video_init (rows, cols); fl_opt.initialized = TRUE; }
TEST(core_signal_test, moved_object_will_not_crash) { Signal signal; Signal signal2(std::move(signal)); signal2(2); }
void signal2_callback(char *proc, int value1, int value2) { int retvalue = 0; if ((retvalue = signal2(proc, value1, value2))) printf("replay:signal2 failed with %d\n", retvalue); }
int main(int argc, char *argv[]) { int value1, value2, value3, mode = 0, retvalue, data_size; char dest_proc[PROC_NAME_SIZE], *datastr; memset(dest_proc, '\0', PROC_NAME_SIZE); /* Parse the parameters */ if (argc < 4) { print_usage(); exit(2); } if (!strcmp(argv[1], "-s1")) { if (argc != 4) { print_usage(); exit(2); } mode = 1; value1 = atoi(argv[3]); strncpy(dest_proc, argv[2], (PROC_NAME_SIZE - 1)); } else if (!strcmp(argv[1], "-s2")) { if (argc != 5) { print_usage(); exit(2); } mode = 2; value1 = atoi(argv[3]); value2 = atoi(argv[4]); strncpy(dest_proc, argv[2], (PROC_NAME_SIZE - 1)); } else if (!strcmp(argv[1], "-s3")) { if (argc != 6) { print_usage(); exit(2); } mode = 3; value1 = atoi(argv[3]); value2 = atoi(argv[4]); value3 = atoi(argv[5]); strncpy(dest_proc, argv[2], (PROC_NAME_SIZE - 1)); } else if (!strcmp(argv[1], "-d")) { if (argc != 4) { print_usage(); exit(2); } mode = 4; data_size = strlen(argv[3]); strncpy(dest_proc, argv[2], (PROC_NAME_SIZE - 1)); datastr = malloc(data_size); strncpy(datastr, argv[3], data_size); } if (mode == 0) { print_usage(); exit(3); } /*set_print_level(CH_DEBUG); */ init_memshare("memsend", 0, 0); switch (mode) { case 1: retvalue = signal1(dest_proc, value1); break; case 2: retvalue = signal2(dest_proc, value1, value2); break; case 3: retvalue = signal3(dest_proc, value1, value2, value3); break; case 4: retvalue = data(dest_proc, datastr, data_size); free(datastr); break; default: /* No place to be */ break; } if (retvalue == 0) exit(0); if (retvalue == 1) { printf("The destination process %s is not present!\n", dest_proc); exit(1); } /* No place to be */ exit(2); }