#!/bin/sh # This is a shar archive. # The rest of this file is a shell script which will extract: # # 3_10.c 3_10ex.c makefile # # To extract the files from this shell archive file simply # create a directory for this file, move the archive file # to it and enter the command # # sh filename # # The files will be extracted automatically. # Note: Do not use csh. # # Archive created: Mon Jul 30 22:59:48 EDT 1990 # echo x - 3_10.c sed 's/^X//' > 3_10.c << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ // rewrite of Duff's Device using memcpy() extern char *memcpy(void*, const void*, int); inline void send(register* to, register* from, register count) { (void) memcpy(to, from, count * sizeof(int)); } !EOF! ls -l 3_10.c echo x - 3_10ex.c sed 's/^X//' > 3_10ex.c << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ void send(register* to, register* from, register count) // Duff's device. Helpful comment deliberately deleted. { register n=(count+7)/8; switch(count%8) { case 0: do { *to++ = *from++; case 7: *to++ = *from++; case 6: *to++ = *from++; case 5: *to++ = *from++; case 4: *to++ = *from++; case 3: *to++ = *from++; case 2: *to++ = *from++; case 1: *to++ = *from++; } while (--n>0); } } !EOF! ls -l 3_10ex.c echo x - makefile sed 's/^X//' > makefile << '!EOF!' CC= CC -I. -I../../CC all: 3_10 3_10: 3_10.c $(CC) -c 3_10.c test: all echo tests done !EOF! ls -l makefile # The following exit is to ensure that extra garbage # after the end of the shar file will be ignored. exit 0