[alt.sources] Buffer: patches for system 5

lmjm@doc.ic.ac.uk (Lee McLoughlin) (07/23/90)

Here are the patches to buffer to allow it to compile under system 5 unix.
(There is also a missing rcs log comment in there.)

I've tested these out under HP-UX 7.0 and Gould UTX 2.1A System 5 emulation.

diff -cr buffer.old/README buffer/README
*** buffer.old/README	Sun Jul 22 18:41:40 1990
--- buffer/README	Sun Jul 22 19:01:01 1990
***************
*** 1,5 ****
  This is a program designed to speed up writing tapes on remote tape
! drives.  It runs on SunOS so long as you have shared memory and locks. 
  
  The program splits itself into two processes.  The first process reads
  (and reblocks) from stdin into a shared memory buffer.  The second
--- 1,8 ----
  This is a program designed to speed up writing tapes on remote tape
! drives.  Requirements are shared memory and locks.
! 
! Buffer has been tested under SunOS 4.0, HP-UX 7.0 and
! Gould UTX 2.1A (sv universe).
  
  The program splits itself into two processes.  The first process reads
  (and reblocks) from stdin into a shared memory buffer.  The second
diff -cr buffer.old/buffer.c buffer/buffer.c
*** buffer.old/buffer.c	Sun Jul 22 18:41:42 1990
--- buffer/buffer.c	Sun Jul 22 18:46:39 1990
***************
*** 9,14 ****
--- 9,21 ----
   * L.McLoughlin, Imperial College, 1990
   *
   * $Log:	buffer.c,v $
+  * Revision 1.5  90/07/22  18:46:38  lmjm
+  * Added system 5 support.
+  * 
+  * Revision 1.4  90/07/22  18:29:48  lmjm
+  * Updated arg handling to be more consistent.
+  * Make sofar printing size an option.
+  * 
   * Revision 1.3  90/05/15  23:27:46  lmjm
   * Added -S option (show how much has been writen).
   * Added -m option to specify how much shared memory to grab.
***************
*** 27,32 ****
--- 34,40 ----
   * 
   */
  #include <stdio.h>
+ #include <signal.h>
  #include <sys/types.h>
  #include <sys/stat.h>
  #include <sys/ipc.h>
***************
*** 34,40 ****
  #include <sys/sem.h>
  
  #ifndef lint
! static char *rcsid = "$Header: /home/gould/staff/csg/lmjm/src/buffer/RCS/buffer.c,v 1.3 90/05/15 23:27:46 lmjm Exp Locker: lmjm $";
  #endif
  
  extern char *shmat();
--- 42,48 ----
  #include <sys/sem.h>
  
  #ifndef lint
! static char *rcsid = "$Header: /home/gould/staff/csg/lmjm/src/buffer/RCS/buffer.c,v 1.5 90/07/22 18:46:38 lmjm Exp Locker: lmjm $";
  #endif
  
  extern char *shmat();
***************
*** 235,241 ****
--- 243,253 ----
  		fprintf( stderr, "pbuffer is 0x%08x, buffer_size is %d [%d x %d]\n",
  			(char *)pbuffer, buffer_size, blocks, blocksize );
  
+ #ifdef SYS5
+ 	memset( (char *)pbuffer, '\0', buffer_size );
+ #else
  	bzero( (char *)pbuffer, buffer_size );
+ #endif
  	pbuffer->blocks_used_lock = -1;
  	pbuffer->blocks_free_lock = -1;
  
diff -cr buffer.old/makefile buffer/makefile
*** buffer.old/makefile	Sun Jul 22 18:41:41 1990
--- buffer/makefile	Sun Jul 22 18:49:54 1990
***************
*** 6,11 ****
--- 6,13 ----
  INSTMAN=/usr/man/manl
  # The manual page section (normally l or 1)
  S=l
+ # Add -DSYS5 for A System 5 (USG) version of unix.
+ CFLAGS=
  
  buffer: buffer.o sem.o
  	$(CC) -o buffer $(CFLAGS) buffer.o sem.o
diff -cr buffer.old/sem.c buffer/sem.c
*** buffer.old/sem.c	Sun Jul 22 18:41:42 1990
--- buffer/sem.c	Sun Jul 22 18:20:51 1990
***************
*** 5,10 ****
--- 5,18 ----
  #include <sys/ipc.h>
  #include <sys/sem.h>
  
+ #ifdef SYS5
+ union semun {
+ 	int val;
+ 	struct semid_ds *buf;
+ 	ushort *array;
+ };
+ #endif
+ 
  /* Set a semaphore to a particular value - meant to be used before
   * first lock/unlock */
  void