int ACE_TMAIN (int, ACE_TCHAR *[]) { int status = 0; for (CORBA::ULong i = 16; i != 64; ++i) { ACE_Message_Block mb (i + ACE_CDR::MAX_ALIGNMENT); ACE_CDR::mb_align (&mb); mb.wr_ptr (i); CORBA::Double dbl = i; TAO_OutputCDR cdr; cdr.write_ulong (i); // length cdr.write_octet_array_mb (&mb); cdr.write_double (dbl); cdr.write_double (dbl); TAO_InputCDR input (cdr); CORBA::ULong len; input.read_ulong (len); if (len != i) { ACE_DEBUG ((LM_DEBUG, "ERROR: mismatched lengths," " got %d, expected %d\n", len, i)); } ACE_Message_Block read_mb (len + ACE_CDR::MAX_ALIGNMENT); ACE_CDR::mb_align (&mb); mb.wr_ptr (len); input.read_char_array (mb.rd_ptr (), len); CORBA::Double read_dbl; if (input.read_double (read_dbl) == 0) ACE_DEBUG ((LM_DEBUG, "Failure reading double...\n")); if (!ACE::is_equal (read_dbl, dbl)) { status = 1; ACE_DEBUG ((LM_DEBUG, "ERROR: mismatched doubles," " got %f, expected %f\n", read_dbl, dbl)); for (const ACE_Message_Block *j = cdr.begin (); j != cdr.end (); j = j->cont ()) { ACE_HEX_DUMP ((LM_DEBUG, j->rd_ptr (), j->length (), ACE_TEXT("Output CDR stream"))); } TAO_InputCDR debug (cdr); ACE_HEX_DUMP ((LM_DEBUG, debug.rd_ptr (), debug.length (), ACE_TEXT("Input CDR stream"))); } } return status; }
int initmembufs(void) { struct if_rxring_info *ifr; field_view *v; int i, mib[4], npools; struct kinfo_pool pool; char pname[32]; size_t size; sock = socket(AF_INET, SOCK_DGRAM, 0); if (sock == -1) { err(1, "socket()"); /* NOTREACHED */ } /* set up the "System" interface */ interfaces = calloc(1, sizeof(*interfaces)); if (interfaces == NULL) err(1, "calloc: interfaces"); ifr = calloc(MCLPOOLS, sizeof(*ifr)); if (ifr == NULL) err(1, "calloc: system pools"); strlcpy(interfaces[0].name, "System", sizeof(interfaces[0].name)); interfaces[0].data.ifri_total = MCLPOOLS; interfaces[0].data.ifri_entries = ifr; num_ifs = 1; /* go through all pools to identify mbuf and cluster pools */ mib[0] = CTL_KERN; mib[1] = KERN_POOL; mib[2] = KERN_POOL_NPOOLS; size = sizeof(npools); if (sysctl(mib, 3, &npools, &size, NULL, 0) < 0) { err(1, "sysctl(KERN_POOL_NPOOLS)"); /* NOTREACHED */ } for (i = 1; i <= npools; i++) { mib[0] = CTL_KERN; mib[1] = KERN_POOL; mib[2] = KERN_POOL_NAME; mib[3] = i; size = sizeof(pname); if (sysctl(mib, 4, &pname, &size, NULL, 0) < 0) { continue; } if (strcmp(pname, "mbpl") == 0) { mbpool_index = i; continue; } if (strncmp(pname, "mcl", 3) != 0) continue; if (mclpool_count == MCLPOOLS) { warnx("mbufs: Too many mcl* pools"); break; } mib[2] = KERN_POOL_POOL; size = sizeof(pool); if (sysctl(mib, 4, &pool, &size, NULL, 0) < 0) { err(1, "sysctl(KERN_POOL_POOL, %d)", i); /* NOTREACHED */ } snprintf(ifr[mclpool_count].ifr_name, sizeof(ifr[mclpool_count].ifr_name), "%dk", pool.pr_size / 1024); ifr[mclpool_count].ifr_size = pool.pr_size; mclpools_index[mclpool_count++] = i; } if (mclpool_count != MCLPOOLS) warnx("mbufs: Unable to read all %d mcl* pools", MCLPOOLS); /* add view to the engine */ for (v = views_mb; v->name != NULL; v++) add_view(v); /* finally read it once */ read_mb(); return(1); }