FUNCTION Msgh *output_buf () { register Msgh *m; register int count = 0; Debug /* first try to allocate space */ m = (Msgh *) l_create (msgdefsize); if (m == NULLMSGH) { /* no space--get desperate */ while (BITTST (report_buf->flags, LOCKED)) { if (count++ == 10000) { /* Wait for the MI to free the buffer.. */ dprintf ("Waiting for report buffer to be unlocked...\n"); count = 0; } } m = report_buf; /* grab report_buf */ } clear ( m, sizeof (Msgh) ); /* clear it */ if ( m == report_buf ) BITSET (m->flags, LOCKED); /* Tell rest of system not to use */ return m; }
FUNCTION Msgh *sysbuf () { register Msgh *m; register int count = 0; Debug /* first try to allocate space */ m = (Msgh *) l_create (msgdefsize); if (m == NULLMSGH) { /* no space--get desperate */ while (BITTST (emergbuf->flags, LOCKED)) { if (count++ == 10000) { /* Wait for the MI to free the buffer.. */ _pprintf ("Waiting for emergbuf to be unlocked... %x\n", emergbuf); send_e_from_q(); /* clear emergbuf */ count = 0; } } m = emergbuf; /* grab emergbuf */ } clear ( m, sizeof (Msgh) ); /* clear it */ if ( m == emergbuf ) BITSET (m->flags, LOCKED); /* Tell rest of system not to use */ return m; }
void big_test() { linked_list list = l_create(); l_add_front(list, 3); length_test(list, 1); front_test(list, 3); back_test(list, 3); //list = 3 l_add_back(list, 4); length_test(list, 2); front_test(list, 3); back_test(list, 4); //list = 3, 4 l_add_front(list, 2); length_test(list, 3); front_test(list, 2); back_test(list, 4); //list = 2, 3, 4 int array1[] = {2, 3, 4}; print_test(list, array1, 3); l_add_front(list, 1); l_add_back(list, 5); length_test(list, 5); front_test(list, 1); back_test(list, 5); //list = 1, 2, 3, 4, 5 find_test(list, 3, 1); link l = l_find(list, 3); l_remove(list, l); find_test(list, 3, 0); length_test(list, 4); front_test(list, 1); back_test(list, 5); //list = 1, 2, 4, 5 int array2[] = {1, 2, 4, 5}; print_test(list, array2, 4); l_remove_back(list); length_test(list, 3); back_test(list, 4); //list = 1, 2, 4 l_remove_front(list); length_test(list, 2); front_test(list, 2); //list = 2, 4 l_destroy(list); }