rose@galtee.cs.wisc.edu (Scott M. Rose) (01/26/91)
Coherent Digest Vol. 91.1, No. 7 Fri Jan 25 11:41:18 CST 1991 Today's Topics: alt.coherent Response to John Welch's compiler bug logname isgraph() fputs() ldiv() bzero() HD drives with > 1024 cylinders RN Administrivia: The Coherent Digest is a forum for discussion of the MWC Coherent 3.x operating system. Send submissions to "coherent@cs.wisc.edu" and administrivia to "coherent-reqeust@cs.wisc.edu". Previous issues are archived for anonymous FTP access on piggy.ucsb.edu in the directory "pub/coherent/mail-list". ---------------------------------------------------------------------- Date: Tue, 22 Jan 91 12:20:11 PST From: curt@cynic.wimsey.bc.ca (Curt Sampson) To: coherent Subject: alt.coherent I've recieved all of 24 replies from people interested in the creation of comp.os.coherent. It's obvious that a vote would not pass. It is also obvious that there are a number of people interested in a newsgroup, and a newsgroup certainly would attract more readers. Therefore I've decided to try and create alt.coherent. Scott Rose (rose@cs.wisc.edu), the moderator of this list, has agreed to post the Coherent digest to the newsgroup on a regular basis and gate everything posted to the newsgroup out to the mailing list. Unless anybody has any bright ideas or severe objections, I'm going to post a call for discucsion for the creation of alt.coherent in alt.config on Thursday. cjs curt@cynic.wimsey.bc.ca | "What do the letters in EBCDIC stand for?" curt@cynic.uucp | "ASCII. 'ASCII' becomes 'EBCDIC' in the {uunet|ubc-cs}!van-bc!cynic!curt | EBCDIC character set." --Steve Connelly ------------------------------ Date: 22 Jan 91 13:44:44 From: mwc!norm@uunet.UU.NET (Norman Bartek) To: cohmail@uunet.UU.NET Cc: hal@uunet.UU.NET Subject: Response to John Welch's compiler bug > I am new to C so this may be a dumb question but I keep running into > internal compiler errors. My brother wrote some code that I have > had trouble porting. After pondering the situation he wrote a test > program which runs on numerous C compilers but gives internal compiler > error no. 1006. > > Could someone at MWC please look at these and perhaps > enlighten me. Thanks in advance Yes, this code does cause the compiler to bomb. The line which exhibits the problem has got to be one of the most convoluted pieces of code that I've seen in quite a while. Calling a function which returns a struct and then taking a member of the struct which is a function pointer and indirecting through it is indeed a punishment for any compiler, even more so on machines that have few available registers and lack of register symmetry (ie: 8086/286). As a temporary work-around, break up line 16 into 2 lines, assigning the result of the first function call's function pointer return value to a local variable. Then perform the second level call on this temporary valiable as follows: main() { void (*vfp)(); vfp = gf()->f; /* get function to be called */ (*vfp)(); /* invoke indirect function */ } Unless your brother is attempting to win the yearly Obfuscated C contest, I'd ask him to avoid overly complex constructs ;-) - -- norm -- ------------------------------ Date: 24 Jan 90 13:44:28 From: trystro!root@Think.COM (Richard Nickle) To: think!fcsys!coherent Subject: logname struct utmp *getutent() sequential calls reveal who is logged on struct utmp *getutline() char *cuserid() returns login-name of current effective-uid (COMMAND) logname I posted this as part of a package of additional functions for Coherent to piggy. I was talking to Gary Clark about the lack of a logname command, and went digging around to make one. Essentially, I repackaged all the UID-stuff I wrote/ported into a cleaner package, seperate from the funcs01.Z that I uploaded to piggy. I will clean up the other stuff too eventually and post it to this 'newsgroup' so you don't have to go scrabbling for it at piggy. Essentially, cut this message off the shar, move it to a directory, unshar it, read the Makefile (it explains what you need to add to stdio.h and utmp.h to get this to work). After you have modified your headers, make it. It will automatically update your /lib/libc.a and also move a program called 'logname' to /usr/local/bin. If you don't want all this stuff to happen automatically, cp the Makefile to a backup, remove the 'ar' and 'mv' from Makefile and play around with a bit before you install it for real. Let me know if you find any bugs, I just tried it, and it worked for me! Rick #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of archive 1 (of 1)." # Contents: Makefile README cuserid.c getutent.c logname.c # Wrapped by root@trystro on Wed Jan 24 13:32:58 1990 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'Makefile' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'Makefile'\" else echo shar: Extracting \"'Makefile'\" \(1136 characters\) sed "s/^X//" >'Makefile' <<'END_OF_FILE' X# UID-Stuff X# X# cuserid written by Rick Nickle (fcsys!trystro@think.com) X# other stuff ported (i.e., 'stolen') by same. X# X# Makefile for certain uid-specific functions: X# X#FUNCTIONS: X# (cuserid.c) X# char *cuserid() returns effective login X# (getutent.c) X# struct utmp *getutent() return information X# struct utmp *getutline() about who is currently logged in. X# X#PROGRAMS: X# logname (logname.c) command to print your effective X# login. certain programs seem X# to need this command X#NOTES: X# add the following to /usr/include/stdio.h: X# X# char *cuserid(); X# X# add the following two lines to /usr/include/utmp.h: X# X# extern struct utmp *getutent(); X# extern struct utmp *getutline(); X# X#I would automate this, but it seems easier (and safer) if you do it. X# X#If you wanna feel even more safe, take out the 'ar' lines in the following X#and throw 'em back in after they compile. They will not overwrite anything X#in Coherent 3.1.0 though, because these functions are not included. X# Xlogname : logname.c X cc -c cuserid.c X cc -c getutent.c X ar rv /lib/libc.a getutent.o cuserid.o X cc logname.c X mv logname /usr/local/bin X END_OF_FILE if test 1136 -ne `wc -c <'Makefile'`; then echo shar: \"'Makefile'\" unpacked with wrong size! fi # end of 'Makefile' fi if test -f 'README' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'README'\" else echo shar: Extracting \"'README'\" \(64 characters\) sed "s/^X//" >'README' <<'END_OF_FILE' XUh, read the Makefile before you do anything. X X--24-Jan-91 Rick END_OF_FILE if test 64 -ne `wc -c <'README'`; then echo shar: \"'README'\" unpacked with wrong size! fi # end of 'README' fi if test -f 'cuserid.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'cuserid.c'\" else echo shar: Extracting \"'cuserid.c'\" \(162 characters\) sed "s/^X//" >'cuserid.c' <<'END_OF_FILE' X#include <pwd.h> X#include <stddef.h> X X/* return name of uid */ X Xchar *cuserid() X{ X struct passwd *entry; X entry = getpwuid(geteuid()); X return entry->pw_name; X} X END_OF_FILE if test 162 -ne `wc -c <'cuserid.c'`; then echo shar: \"'cuserid.c'\" unpacked with wrong size! fi # end of 'cuserid.c' fi if test -f 'getutent.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'getutent.c'\" else echo shar: Extracting \"'getutent.c'\" \(1324 characters\) sed "s/^X//" >'getutent.c' <<'END_OF_FILE' X/** X ** Simulate SysV getutent(3) calls, as best as can be done in X ** a System III environment, at least. X ** X ** Author: Paul Sutcliffe, Jr. <paul@devon.uucp> X ** X ** I hereby place this in the public domain. X ** No warranties expressed or implied. X **/ X X#include <stdio.h> X#include <string.h> X#include <sys/types.h> X#include <utmp.h> X Xstatic char *utmpfil = "/etc/utmp"; /* default utmp file */ Xstatic FILE *ufp = NULL; /* file pointer to utmp file */ X /* NULL = no utmp file open */ Xstatic struct utmp ut; /* buffer for utmp record */ X Xstruct utmp *getutent(), *getutline(); Xvoid pututline(), setutent(), endutent(), utmpname(); X Xstruct utmp * Xgetutent() X{ X FILE *fopen(); X X if (ufp == NULL) { X if ((ufp = fopen(utmpfil, "r+")) == NULL) { X return((struct utmp *)NULL); X } X } X do { X if (fread((char *)&ut, sizeof(ut), 1, ufp) != 1) { X return((struct utmp *)NULL); X } X } while (ut.ut_name[0] == 0); /* valid entry? */ X X return(&ut); X} X Xstruct utmp * Xgetutline(line) Xstruct utmp *line; X{ X do { X if (strcmp(ut.ut_line, line->ut_line) == 0) { X return(&ut); X } X } while (getutent() != (struct utmp *)NULL); X X return((struct utmp *)NULL); X} X Xvoid Xsetutent() X{ X if (ufp != NULL) rewind(ufp); X} X Xvoid Xendutent() X{ X if (ufp != NULL) fclose(ufp); X} X Xvoid Xutmpname(file) Xchar *file; X{ X utmpfil = file; X} END_OF_FILE if test 1324 -ne `wc -c <'getutent.c'`; then echo shar: \"'getutent.c'\" unpacked with wrong size! fi # end of 'getutent.c' fi if test -f 'logname.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'logname.c'\" else echo shar: Extracting \"'logname.c'\" \(287 characters\) sed "s/^X//" >'logname.c' <<'END_OF_FILE' X/* this should return the effective login-name */ X/* sorta like 'who' but without that junk about */ X/* which tty you are on, etc. */ X/* Rick Nickle, Jan 24, 1991 */ X/* fcsys!trystro!rick@think.com */ X X#include <utmp.h> X#include <stddef.h> X Xmain() X X{ X printf("%s\n",cuserid()); X} END_OF_FILE if test 287 -ne `wc -c <'logname.c'`; then echo shar: \"'logname.c'\" unpacked with wrong size! fi # end of 'logname.c' fi echo shar: End of archive 1 \(of 1\). cp /dev/null ark1isdone MISSING="" for I in 1 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have the archive. rm -f ark[1-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0 ------------------------------ Date: 24 Jan 90 14:28:36 From: trystro!root@Think.COM (Richard Nickle) To: think!coherent@bob gary fcsys Subject: isgraph() This is pretty simple, I needed it for a port but it wasn't in ctype.h #define isgraph(c) ((isprint(c) && !isspace(c))) ------------------------------ Date: 24 Jan 90 14:04:44 From: trystro!root@Think.COM (Richard Nickle) To: think!coherent@gary bob fcsys Subject: fputs() Distributed to....gary, bob, coherent@cs.wisc.edu This is a small fix for fputs I posted to piggy. If somebody already posted it, I'm sorry for the bandwidth lost. (I only started recieving this 'conference' this week.) Strip this useless verbiage off the top of the shar, unshar it, read the Makefile, and when satisfied you need this program, type 'make'. Sincerely, Rick #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of archive 1 (of 1)." # Contents: Makefile fputs.c # Wrapped by root@trystro on Wed Jan 24 13:59:20 1990 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'Makefile' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'Makefile'\" else echo shar: Extracting \"'Makefile'\" \(913 characters\) sed "s/^X//" >'Makefile' <<'END_OF_FILE' X#WHO X# Rick Nickle, fcsys!trystro!rick@think.com X# (Really, Kernighan and Ritchie wrote it, I stole it from X# the K+R Second Edition) X#WHAT X# int fputs(s,iop) X# char *s; X# FILE *s; X#WHEN X# Jan 24, 1991 (I did this in November and e-mailed it X# and a bunch of other fixes.....but got no response) X# X#WHY X# I was trying to port something (cnews, which never got done) X# and I had trouble because the program in question was expecting X# fputs() to return an int. X#HOW X# X# Change the declaration in /usr/include/stdio.h for fputs(); X# to 'int fputs();'. X# X# Type Make, this program will automatically replace the X# existing fputs.o in /lib/libc.a with this version. X# X# Just to be sure, it'll extract the original (3.?.0) to X# current directory as 'fputs.o.old' in case you have trouble X# with it. X# Xfputs.o : fputs.c X ar xv /lib/libc.a fputs.o X mv fputs.o fputs.old X cc -c fputs.c X ar rv /lib/libc.a fputs.o END_OF_FILE if test 913 -ne `wc -c <'Makefile'`; then echo shar: \"'Makefile'\" unpacked with wrong size! fi # end of 'Makefile' fi if test -f 'fputs.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'fputs.c'\" else echo shar: Extracting \"'fputs.c'\" \(431 characters\) sed "s/^X//" >'fputs.c' <<'END_OF_FILE' X/* uh, why doesn't Coherent 3.0.0 have an int- */ X/* returning fputs like everyone else? */ X/* */ X/* STOLEN directly from K+R C 2nd Ed. (pg. 165) */ X/* */ X/* change 'void' to 'int' in stdio.h before */ X/* compiling this. then, go ahead an replace */ X/* the fputs in /lib/libc.a */ X X#include <stdio.h> X Xint fputs(s,iop) Xchar *s; XFILE *iop; X{ X int c; X X while (c = *s++) X putc(c,iop); X return ferror(iop) ? EOF : 0; X} END_OF_FILE if test 431 -ne `wc -c <'fputs.c'`; then echo shar: \"'fputs.c'\" unpacked with wrong size! fi # end of 'fputs.c' fi echo shar: End of archive 1 \(of 1\). cp /dev/null ark1isdone MISSING="" for I in 1 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have the archive. rm -f ark[1-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0 ------------------------------ Date: 24 Jan 90 14:36:10 From: trystro!root@Think.COM (Richard Nickle) To: think!coherent@gary bob fcsys Subject: ldiv() This is an addition to libc.a for ldiv(), yet another function I needed when I was porting (i think it was for cnews). If you already have it, sorry about the wasted bandwidth, I just got onto this 'newsgroup' this week. I've already posted this and other fixes to piggy, and will repost a new version of funcs01.Z soon (with the Makefiles and better docs that I just wrote this afternoon). Cut this message off the shell archive and unshar in it's own directory. Follow the directions in 'README' and away you go... Rick #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of archive 1 (of 1)." # Contents: Makefile README ldiv.c # Wrapped by root@trystro on Wed Jan 24 14:32:40 1990 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'Makefile' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'Makefile'\" else echo shar: Extracting \"'Makefile'\" \(61 characters\) sed "s/^X//" >'Makefile' <<'END_OF_FILE' X/lib/libc.a : ldiv.o X ar rv /lib/libc.a ldiv.o X cat README END_OF_FILE if test 61 -ne `wc -c <'Makefile'`; then echo shar: \"'Makefile'\" unpacked with wrong size! fi # end of 'Makefile' fi if test -f 'README' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'README'\" else echo shar: Extracting \"'README'\" \(547 characters\) sed "s/^X//" >'README' <<'END_OF_FILE' XTo finish the job, add the following to stddef.h X X typedef struct { X long quot; X long rem; X } ldiv_t; X X ldiv_t ldiv(); X XANSI C defines the ldiv_t type to be located in stdlib.h. My answer Xto this is to make a link of stdlib.h to stddef.h. X XIt also defines the prototype of ldiv to be in stdio.h, but that got Xcomplicated, because then I'd have to throw an include in stdio.h Xto include stdlib.h, so i put the proto in stdlib.h/stddef.h. X X ln /usr/include/stddef.h /usr/include/stdlib.h X XHope this helps. X XEMAIL: fcsys!trystro!rick@think.com X END_OF_FILE if test 547 -ne `wc -c <'README'`; then echo shar: \"'README'\" unpacked with wrong size! fi # end of 'README' fi if test -f 'ldiv.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'ldiv.c'\" else echo shar: Extracting \"'ldiv.c'\" \(594 characters\) sed "s/^X//" >'ldiv.c' <<'END_OF_FILE' X/* ldiv function for Coherent 3.0.0 */ X/* */ X/* compute quotient and remainder of two */ X/* longs, storing in struct ldiv_t */ X/* */ X/* (quick & dirty) richard nickle */ X/* 20-nov-90 */ X/* fcsys!trystro!rick@think.com */ X Xtypedef struct { /* my advice: add this to */ X long quot; /* stddef.h AND link stddef.h */ X long rem; /* to stdlib.h (non-existent in */ X } ldiv_t; /* release 3.0.0. */ X Xldiv_t *ldiv(num,denom) Xlong num, denom; X{ X ldiv_t scratch; X X for (scratch.quot=0,scratch.rem=0;((num -= denom) > 0);scratch.quot++) X X scratch.rem = num; X X return &scratch; X} X END_OF_FILE if test 594 -ne `wc -c <'ldiv.c'`; then echo shar: \"'ldiv.c'\" unpacked with wrong size! fi # end of 'ldiv.c' fi echo shar: End of archive 1 \(of 1\). cp /dev/null ark1isdone MISSING="" for I in 1 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have the archive. rm -f ark[1-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0 ------------------------------ Date: 24 Jan 90 22:13:35 From: trystro!root@Think.COM (Richard Nickle) To: think!fcsys!coherent Subject: bzero() #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of archive 1 (of 1)." # Contents: bzero.c bzero.man # Wrapped by root@trystro on Tue Jan 22 01:09:24 1991 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'bzero.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'bzero.c'\" else echo shar: Extracting \"'bzero.c'\" \(176 characters\) sed "s/^X//" >'bzero.c' <<'END_OF_FILE' X/* bzero function for Coherent 3.0.0 */ X/* place length 0 bytes in string */ X/* */ X Xbzero(b,len) Xchar *b; Xint len; X{ X char *p = b; X for (;len>0;len--) { X *p++=0; X } X} X X END_OF_FILE if test 176 -ne `wc -c <'bzero.c'`; then echo shar: \"'bzero.c'\" unpacked with wrong size! fi # end of 'bzero.c' fi if test -f 'bzero.man' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'bzero.man'\" else echo shar: Extracting \"'bzero.man'\" \(1345 characters\) sed "s/^X//" >'bzero.man' <<'END_OF_FILE' X X XBSTRING(3) UNIX Programmer's Manual BSTRING(3) X X XNAME X bcopy, bcmp, bzero, ffs - bit and byte string operations X XSYNOPSIS X bcopy(src, dst, length) X char *src, *dst; X int length; X X bcmp(b1, b2, length) X char *b1, *b2; X int length; X X bzero(b, length) X char *b; X int length; X X ffs(i) X int i; X XDESCRIPTION X The functions _b_c_o_p_y, _b_c_m_p, and _b_z_e_r_o operate on variable X length strings of bytes. They do not check for null bytes X as the routines in _s_t_r_i_n_g(3) do. X X _B_c_o_p_y copies _l_e_n_g_t_h bytes from string _s_r_c to the string _d_s_t. X X _B_c_m_p compares byte string _b_1 against byte string _b_2, return- X ing zero if they are identical, non-zero otherwise. Both X strings are assumed to be _l_e_n_g_t_h bytes long. X X _B_z_e_r_o places _l_e_n_g_t_h 0 bytes in the string _b_1. X X _F_f_s find the first bit set in the argument passed it and X returns the index of that bit. Bits are numbered starting X at 1. A return value of 0 indicates the value passed is X zero. X XBUGS X The _b_c_o_p_y routine take parameters backwards from _s_t_r_c_p_y. X X X X X X X X X X X X X X X X X XPrinted 12/16/89 May 15, 1985 1 X X X X END_OF_FILE echo shar: 78 control characters may be missing from \"'bzero.man'\" if test 1345 -ne `wc -c <'bzero.man'`; then echo shar: \"'bzero.man'\" unpacked with wrong size! fi # end of 'bzero.man' fi echo shar: End of archive 1 \(of 1\). cp /dev/null ark1isdone MISSING="" for I in 1 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have the archive. rm -f ark[1-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0 ------------------------------ Date: 25 Jan 91 00:48:45 From: citrus!root@csusac.ecs.csus.edu (Joel M. Baldwin Superuser) To: coherent@csusac.ecs.csus.edu% Cc: root@csusac.ecs.csus.edu% Subject: HD drives with > 1024 cylinders If there is anyone on the list that would like to know how to get coherent to work with drives that have more than 1024 cylinders, get in touch with me. I just finished figuring out how to get coherent to see all 1314 cylinders of my Microscience HH1090 hard drive. Now fdisk gives me a display of: Drive 1 currently has the following logical partitions: [ In Cylinders ] [ In Tracks ] Number Type Start End Size Start End Size Megabytes Name 4 Boot Coherent 0 1313 1314 1 9197 9197 80.05 /dev/rat1a 5 <Unused> 0 0 0 0 0 0 0.00 /dev/rat1b 6 <Unused> 0 0 0 0 0 0 0.00 /dev/rat1c 7 <Unused> 0 0 0 0 0 0 0.00 /dev/rat1d Isn't that pretty! : ) Joel M. Baldwin H ( 916 ) 383-9470 N6NPL W " 452-1481 uunet!csusac.ecs.csus.edu!citrus!root Sacramento CA. /\++/\ ------------------------------ Date: Fri, 25 Jan 91 11:35:50 -0600 From: "Predrag S. Bundalo" <pred@iitmax.iit.edu> To: coherent Subject: RN Yesterday, someone posted that rn(1) was available for minix in comp.os.minix with the following message_id (should you want to read it yourself): <1991Jan23.232429.15738@jarvis.csri.toronto.edu> Maybe someone would like to port it (hint, hint). There's only one problem: it's too big, so you'll have to cut out some of the less-used features. -Pred ______________________________________________________________________________ Predrag S. Bundalo Internet: pred@iitmax.iit.edu Illinois Institute of Technology Internet: SysPredrag@Karl.iit.edu Academic Computing Center BITNET : SysPredrag@iitVax VAX/VMS and Unix Systems Staff Internet: pred@elof.iit.edu Chicago, Illinois ------------------------------ End of Coherent Digest Vol. 91.1, No. 7 *************************************** -- Scott Rose rose@cs.wisc.edu