Path: utzoo!attcan!uunet!lll-winken!lll-tis!ames!ucsd!rutgers!njin!princeton!udel!mmdf From: frank@morgan.com (Frank Wortner) Newsgroups: comp.os.minix Subject: Re: Minix C Compiler Sources from UniPress Software -- What do I get? Message-ID: <3486@louie.udel.EDU> Date: 26 Jul 88 15:20:13 GMT Sender: mmdf@udel.EDU Lines: 60 In article <14648@santra.UUCP> Tapani Lindgren writes: >A few months ago I tried to install the Minix C compiler on a Sun-4. >I was able to compile the compiler (after a few minor changes), >but it refused to do anything sensible. > >Are there any known problems with the MinixCC/Sun4-combination? >Any bugs that depend on word length or byte order of the CPU? I know of one problem Minix cc has on Sun 4s (and other machines). The ACK/Minix authors were rather cavelier in their handling of variable argument lists. They assumed that all processors passed arguments on the stack just like PDP-11s, VAXen, and 8086s. Unfortunately, Sun 4s do not. The ACK explicitly takes addresses of argument lists and uses pointers to index through these lists. Here's an example (taken from Minix cc.c): char * mkstr(dst, arg) char *dst, *arg; { char **vec = (char **) &arg; /* WRONG !!!! */ register char *p; register char *q = dst; while (p = *vec++) { /* WRONG !!!! */ while (*q++ = *p++); q--; } return dst; } Here is the same example written portably using varargs(3) (available in most modern C compilers): /* This works on Sun 4 (and everywhere else) */ char *mkstr(va_alist) va_dcl { va_list ap; char *dst; register char *p, *q; va_start(ap); q = dst = va_arg(ap, char *); while ((p = va_arg(ap, char *)) != (char *)0) { while (*q++ = *p++); q--; } va_end(ap); return dst; } (In case you're wondering, the function takes two or more strings and concatenates them.) Minix source isn't as portable or well written as it could be, but neither was 1970s vintage Un*x. Frank