source: buchla-68k/orig/GP/TESTWQ.C@ 6888aa2

Last change on this file since 6888aa2 was 3ae31e9, checked in by Thomas Lopatic <thomas@…>, 7 years ago

Imported original source code.

  • Property mode set to 100755
File size: 1.9 KB
Line 
1/*
2 =============================================================================
3 testwq.c -- test the word queue functions
4 Version 1 -- 1988-11-02 -- D.N. Lynx Crowe
5 =============================================================================
6*/
7
8#include "stdio.h"
9#include "stddefs.h"
10#include "wordq.h"
11
12#define QSIZE 128 /* queue length (words) for testing */
13
14#define QLO (QSIZE >> 2) /* lo water mark = 1/4 queue length */
15#define QHI (QSIZE - QLO) /* hi water mark = 3/4 queue length */
16
17/*
18 =============================================================================
19 Test the word queue functions
20 =============================================================================
21*/
22
23struct wordq queue1;
24
25unsigned short words[QSIZE];
26
27unsigned short rs;
28
29main(argc, argv)
30int argc;
31char *argv[];
32{
33 register struct wordq *qp;
34 register unsigned short i, qsiz;
35 register short rc;
36
37 qp = &queue1;
38
39 printf("Initializing queue: size = %u, lo water = %u, hi water = %u\n",
40 QSIZE, QLO, QHI);
41
42 if (QSIZE NE (qsiz = setwq(qp, words, QSIZE, QHI, QLO))) {
43
44 printf("ERROR -- setwq() returned %u\n", qsiz);
45 exit(1);
46 }
47
48 printf("Filling queue of length %u with %u entries\n",
49 QSIZE, QSIZE + 2);
50
51 for (i = 0; i < QSIZE + 2; i++) { /* fill queue to overflow */
52
53 if (rc = putwq(qp, i))
54 printf("putwq() returned %d on entry %u\n",
55 rc, i);
56 }
57
58 printf("Queue $%08.8lx: size = %u, len = %u, in = %u, out = %u\n",
59 qp, qp->qsize, qp->qlen, qp->qin, qp->qout);
60
61 printf("Emptying queue of length %u for %u entries\n",
62 QSIZE, QSIZE + 2);
63
64 for (i = 0; i < QSIZE + 2; i++) { /* empty queue to underflow */
65
66 if (rc = getwq(qp, &rs))
67 printf("getwq() returned %d on entry %u\n",
68 rc, i);
69
70 if ((rs NE i) AND (i < QSIZE))
71 printf("ERROR -- value %u should have been %u\n",
72 rs, i);
73 }
74
75 exit(0);
76}
Note: See TracBrowser for help on using the repository browser.