*/
word entier(double x)
{
- word i;
-
- if (x >= 0.0)
- {
- i = (word)x;
- return(i);
- }
- else
- {
- i = (word)(-x);
- i = -i;
- if ((double)i <= x) return(i); else return(i-1);
- }
+ word i;
+
+ if (x >= 0.0) {
+ i = (word)x;
+ return i;
+ } else {
+ i = (word)(-x);
+ i = -i;
+ if ((double)i <= x)
+ return i;
+ else
+ return i - 1;
+ }
}
/**
*/
word shift(word x, word n)
{
- if (n == 0) return (x);
- if (n > 0) return (x << n);
- else return ( (x >> -n) & ~(~(word)0 << (8*sizeof(word)+n)) );
+ if (n == 0)
+ return (x);
+ if (n > 0)
+ return (x << n);
+ else
+ return ((x >> -n) & ~(~(word)0 << (8 * sizeof(word) + n)));
}
*/
char *asciiz(virtaddr *virt)
{
- word am;
- int len, i;
- char *cp;
-
- if (member(virt, &am))
- {
- len = M[ am ]-3; /* length of the string */
- cp = ballocate(len+1); /* allocate buffer for the string */
- if (cp == NULL) errsignal(RTEMEMOV);
- for (i = 0; i < len; i++) cp[ i ] = (char) M[ am+3+i ];
- cp[ len ] = '\0'; /* terminate string with 0 byte */
- return (cp);
- }
- else errsignal(RTEREFTN); /* reference to none */
+ word am;
+ int len, i;
+ char *cp;
+
+ if (member(virt, &am)) {
+ /* length of the string */
+ len = M[am] - 3;
+ /* allocate buffer for the string */
+ cp = ballocate(len + 1);
+
+ if (cp == NULL)
+ errsignal(RTEMEMOV);
+
+ for (i = 0; i < len; i++)
+ cp[i] = (char) M[am + 3 + i];
+
+ /* terminate string with 0 byte */
+ cp[len] = '\0';
+ return cp;
+ }
+ else {
+ /* reference to none */
+ errsignal(RTEREFTN);
+ }
}
/**
*/
void addext(char *fname, char *ext)
{
- char *cp;
+ char *cp;
- cp = fname;
- while (*cp != '\0' && *cp != '.') cp++;
- strcpy(cp, ext);
+ cp = fname;
+ while (*cp != '\0' && *cp != '.')
+ cp++;
+ strcpy(cp, ext);
}
void usage()
*/
void abend(char *msg)
{
- fprintf(stderr, "Error: %s\n", msg);
- exit(8);
-} /* end abend */
+ fprintf(stderr, "Error: %s\n", msg);
+ exit(8);
+}
/* Pseudo random number generator */
*/
void ranset()
{
- long tim;
+ long tim;
- time(&tim);
- ranpat1 = tim % 30269;
- ranpat2 = tim % 30307;
- ranpat3 = tim % 30323;
+ time(&tim);
+ ranpat1 = tim % 30269;
+ ranpat2 = tim % 30307;
+ ranpat3 = tim % 30323;
}
/**
*/
double prandom()
{
- int i;
- double r;
-
- ranpat1 = 171*(ranpat1 % 177)- 2*(ranpat1 / 177);
- if (ranpat1 < 0) ranpat1 += 30269;
- ranpat2 = 172*(ranpat2 % 176)-35*(ranpat2 / 176);
- if (ranpat2 < 0) ranpat2 += 30307;
- ranpat3 = 170*(ranpat3 % 178)-63*(ranpat3 / 178);
- if (ranpat3 < 0) ranpat3 += 30323;
- r = ranpat1/30269.0 + ranpat2/30307.0 + ranpat3/30323.0;
- i = (int)r;
- return (r-i);
+ int i;
+ double r;
+
+ ranpat1 = 171 * (ranpat1 % 177) - 2 * (ranpat1 / 177);
+ if (ranpat1 < 0)
+ ranpat1 += 30269;
+
+ ranpat2 = 172 * (ranpat2 % 176) - 35 * (ranpat2 / 176);
+
+ if (ranpat2 < 0)
+ ranpat2 += 30307;
+
+ ranpat3 = 170 * (ranpat3 % 178) - 63 * (ranpat3 / 178);
+
+ if (ranpat3 < 0)
+ ranpat3 += 30323;
+
+ r = ranpat1 / 30269.0 + ranpat2 / 30307.0 + ranpat3 / 30323.0;
+ i = (int)r;
+ return r - i;
}
/**
/**************************************************************
-#define LINE 10
-void dump(pix, from, len)
-word pix, from;
-int len;
+#define LINE 10
+void dump(word pix, word from, int len)
{
- int i;
- memory M;
-
- M = process[ pix ].M;
- while (len > 0)
- {
- printf("%6ld: ", (long) from);
- for (i = 0; i < LINE; i++) printf("%7ld", (long)M[from++]);
- putchar('\n');
- len -= LINE;
- }
+ int i;
+ memory M;
+
+ M = process[pix].M;
+ while (len > 0) {
+ printf("%6ld: ", (long) from);
+ for (i = 0; i < LINE; i++)
+ printf("%7ld", (long)M[from++]);
+ putchar('\n');
+ len -= LINE;
+ }
}
-
**************************************************************/