Newsgroups: comp.sources.misc From: Warren Tucker Subject: v22i094: ecu - ECU async comm package rev 3.10, Patch05e/5 Message-ID: <1991Sep4.160303.28501@sparky.IMD.Sterling.COM> X-Md4-Signature: 998c113846c0f2652c296b847d576e46 Date: Wed, 4 Sep 1991 16:03:03 GMT Approved: kent@sparky.imd.sterling.com Submitted-by: Warren Tucker Posting-number: Volume 22, Issue 94 Archive-name: ecu/patch05e Environment: SCO, XENIX, ISC, SUNOS4.1, SYSVR4 Patch-To: ecu: Volume 21, Issue 53-89 #!/bin/sh # this is p5.05 (part 5 of ecu/patch05) # do not concatenate these parts, unpack them in order with /bin/sh # file memmove/memmove.s continued # if test ! -r _shar_seq_.tmp; then echo 'Please unpack part 1 first!' exit 1 fi (read Scheck if test "$Scheck" != 5; then echo Please unpack part "$Scheck" next! exit 1 else exit 0 fi ) < _shar_seq_.tmp || exit 1 if test ! -f _shar_wnt_.tmp; then echo 'x - still skipping memmove/memmove.s' else echo 'x - continuing file memmove/memmove.s' sed 's/^X//' << 'SHAR_EOF' >> 'memmove/memmove.s' && X .globl _mcount X call _mcount X') X push %edi X push %esi X mov 12(%esp),%edi X mov 16(%esp),%esi X mov 20(%esp),%ecx X mov %edi,%eax / return value: dest X jcxz mm_exit X X mov %edi,%edx X sub %esi,%edx X jb mm_simple X cmp %edx,%ecx X jb mm_simple X X add %ecx,%edi X dec %edi X add %ecx,%esi X dec %esi X std X rep; movsb X cld X jmp mm_exit X Xmm_simple: X cld X mov %ecx,%edx X shr $2,%ecx X rep; movs X mov %edx,%ecx X and $3,%ecx X rep; movsb X Xmm_exit: X pop %esi X pop %edi X ret SHAR_EOF echo 'File memmove/memmove.s is complete' && chmod 0664 memmove/memmove.s || echo 'restore of memmove/memmove.s failed' Wc_c="`wc -c < 'memmove/memmove.s'`" test 1143 -eq "$Wc_c" || echo 'memmove/memmove.s: original size 1143, current size' "$Wc_c" rm -f _shar_wnt_.tmp fi # ============= memmove/memmove286.asm ============== if test -f 'memmove/memmove286.asm' -a X"$1" != X"-c"; then echo 'x - skipping memmove/memmove286.asm (File already exists)' rm -f _shar_wnt_.tmp else > _shar_wnt_.tmp echo 'x - extracting memmove/memmove286.asm (Text)' sed 's/^X//' << 'SHAR_EOF' > 'memmove/memmove286.asm' && X;+------------------------------------------------------------------ X; memmove386.asm X; X; Name X; memmove - Copies characters between objects. X; X; Syntax X; X; void *memmove(dest, src, count) X; void *dest; X; const void *src; X; size_t count; X; X; Description X; The memmove function copies count characters from src to X; dest. If some regions of src and dest overlap, memmove X; ensures that the original src bytes in the overlapping X; region are copied before being overwritten. X; X; Return Value X; The value of dest, the destination object. X; X;------------------------------------------------------------------- X;+:EDITS: X;:09-01-1991-23:15-wht@n4hgf-convert Chip's memmove.s X X TITLE memmove286.asm X .286p X .287 XMEMMOVE_TEXT SEGMENT WORD PUBLIC 'CODE' XMEMMOVE_TEXT ENDS X_DATA SEGMENT WORD PUBLIC 'DATA' X_DATA ENDS XCONST SEGMENT WORD PUBLIC 'CONST' XCONST ENDS X_BSS SEGMENT WORD PUBLIC 'BSS' X_BSS ENDS XDGROUP GROUP CONST, _BSS, _DATA X ASSUME CS: MEMMOVE_TEXT, DS: DGROUP, SS: DGROUP XEXTRN __chkstk:FAR XMEMMOVE_TEXT SEGMENT X ASSUME CS: MEMMOVE_TEXT X Xdest equ 6 Xsrc equ 10 Xlen equ 14 X X PUBLIC _memmove X_memmove PROC FAR X push bp X mov bp,sp X mov ax,0 X call FAR PTR __chkstk X push di X push si X push ds X X mov ax,WORD PTR [bp+src] X mov dx,WORD PTR [bp+src+2] X mov cx,WORD PTR [bp+len] X mov si,ax X mov ds,dx X les di,DWORD PTR [bp+dest] X mov dx,es X X; which way should the copy go? X mov ax,di X sub ax,si X jb short mm_ascend X cmp cx,ax X jb short mm_ascend X X; descending X add si,cx X dec si X add di,cx X dec di X std X rep movsb X cld X jmp short mm_exit X X; ascending Xmm_ascend: X cld X shr cx,1 X rep movsw X adc cx,cx X rep movsb X Xmm_exit: X pop ds X pop si X pop di X leave X ret X X_memmove ENDP X_TEXT ENDS X end SHAR_EOF chmod 0644 memmove/memmove286.asm || echo 'restore of memmove/memmove286.asm failed' Wc_c="`wc -c < 'memmove/memmove286.asm'`" test 1745 -eq "$Wc_c" || echo 'memmove/memmove286.asm: original size 1745, current size' "$Wc_c" rm -f _shar_wnt_.tmp fi # ============= memmove/memmove386.asm ============== if test -f 'memmove/memmove386.asm' -a X"$1" != X"-c"; then echo 'x - skipping memmove/memmove386.asm (File already exists)' rm -f _shar_wnt_.tmp else > _shar_wnt_.tmp echo 'x - extracting memmove/memmove386.asm (Text)' sed 's/^X//' << 'SHAR_EOF' > 'memmove/memmove386.asm' && X;+------------------------------------------------------------------ X; memmove386.asm X; X; Name X; memmove - Copies characters between objects. X; X; Syntax X; X; void *memmove(dest, src, count) X; void *dest; X; const void *src; X; size_t count; X; X; Description X; The memmove function copies count characters from src to X; dest. If some regions of src and dest overlap, memmove X; ensures that the original src bytes in the overlapping X; region are copied before being overwritten. X; X; Return Value X; The value of dest, the destination object. X; X;------------------------------------------------------------------- X;+:EDITS: X;:09-01-1991-23:15-wht@n4hgf-convert Chip's memmove.s X X TITLE $memmove X X .386 XDGROUP GROUP CONST, _BSS, _DATA X_DATA SEGMENT DWORD USE32 PUBLIC 'DATA' X_DATA ENDS X_BSS SEGMENT DWORD USE32 PUBLIC 'BSS' X_BSS ENDS XCONST SEGMENT DWORD USE32 PUBLIC 'CONST' XCONST ENDS X ASSUME CS: _TEXT, DS: DGROUP, SS: DGROUP, ES: DGROUP X X PUBLIC _memmove X PUBLIC memmove X X_TEXT SEGMENT DWORD USE32 PUBLIC 'CODE' X_memmove PROC NEAR Xmemmove: X push edi X push esi X mov edi,[esp+12] X mov esi,[esp+16] X mov ecx,[esp+20] X mov eax,edi ; return value: dest X jcxz mm_exit X X mov edx,edi X sub edx,esi X jb short mm_left_to_right X cmp ecx,edx X jb short mm_left_to_right X Xmm_right_to_left: X add edi,ecx X dec edi X add esi,ecx X dec esi X std X rep movsb X cld X jmp short mm_exit X Xmm_left_to_right: X cld X mov edx,ecx X shr ecx,2 X rep movsw X mov ecx,edx X and ecx,3 X rep movsb X Xmm_exit: X pop esi X pop edi X ret X_memmove ENDP X_TEXT ENDES X end SHAR_EOF chmod 0644 memmove/memmove386.asm || echo 'restore of memmove/memmove386.asm failed' Wc_c="`wc -c < 'memmove/memmove386.asm'`" test 1587 -eq "$Wc_c" || echo 'memmove/memmove386.asm: original size 1587, current size' "$Wc_c" rm -f _shar_wnt_.tmp fi # ============= timetest/Makefile ============== if test ! -d 'timetest'; then echo 'x - creating directory timetest' mkdir 'timetest' fi if test -f 'timetest/Makefile' -a X"$1" != X"-c"; then echo 'x - skipping timetest/Makefile (File already exists)' rm -f _shar_wnt_.tmp else > _shar_wnt_.tmp echo 'x - extracting timetest/Makefile (Text)' sed 's/^X//' << 'SHAR_EOF' > 'timetest/Makefile' && X XPROGS = seltest naptest naptest2 naptest3 X XLIB = -lx # -linet # needed on ISC X Xall: $(PROGS) X X# -linet needed on ISC Xseltest: seltest.c X cc -o $@ $@.c X Xnaptest: seltest.c X cc -o $@ $@.c $(LIB) X Xnaptest2: seltest.c X cc -o $@ $@.c $(LIB) X Xnaptest3: seltest.c X cc -o $@ $@.c $(LIB) X Xclean: X rm -f $(PROGS) SHAR_EOF chmod 0664 timetest/Makefile || echo 'restore of timetest/Makefile failed' Wc_c="`wc -c < 'timetest/Makefile'`" test 304 -eq "$Wc_c" || echo 'timetest/Makefile: original size 304, current size' "$Wc_c" rm -f _shar_wnt_.tmp fi # ============= timetest/naptest.c ============== if test -f 'timetest/naptest.c' -a X"$1" != X"-c"; then echo 'x - skipping timetest/naptest.c (File already exists)' rm -f _shar_wnt_.tmp else > _shar_wnt_.tmp echo 'x - extracting timetest/naptest.c (Text)' sed 's/^X//' << 'SHAR_EOF' > 'timetest/naptest.c' && X/* CHK=0x88E6 */ X/*+------------------------------------------------------------------------- X naptest.c - nap test suite X wht@n4hgf.Mt-Park.GA.US X XThis little program is derived from my first nap program from XENIX days. XThe M_XENIX code shows how predictable nap() behaves under XENIX 286 Xand 386. It assumes HZ is 50. It surely was nice when UNIX came out Xwith 100 HZ for 10 msec clock ticks. 60 HZ 16.6666666666666666666667 Xmsec clock ticks are a bit nauseating. X--------------------------------------------------------------------------*/ X/*+:EDITS:*/ X/*:06-26-1988-14:05-wht-creation */ X X#include X#ifdef M_UNIX X#undef M_XENIX X#endif X X#ifndef M_XENIX X#include X#endif X Xmain(argc,argv,envp) Xint argc; Xchar **argv; Xchar **envp; X{ X register int itmp; X long nap(),ms; X int cnt[8]; X X for(itmp = 0; itmp < 8; itmp++) X cnt[itmp] = 0; X X#ifdef M_XENIX X printf("making 1000 nap(20L) calls\n"); X for(itmp = 0; itmp < 1000; itmp++) X { X switch(nap((long)20)) X { X case 0L: cnt[0]++; break; X case 20L: cnt[1]++; break; X case 40L: cnt[2]++; break; X case 60L: cnt[3]++; break; X case 80L: cnt[4]++; break; X case 100L: cnt[5]++; break; X case 120L: cnt[6]++; break; X default: cnt[7]++; break; X } X } X printf("return value buckets:\n"); X printf("0:%d 20:%d 40:%d 60:%d 80:%d 100:%d 120:%d other:%d\n", X cnt[0],cnt[1],cnt[2],cnt[3],cnt[4],cnt[5],cnt[6],cnt[7]); X#else X printf("making 1000 nap(%ldL) calls\n",(1000 / HZ) + 1); X for(itmp = 0; itmp < 1000; itmp++) X { X switch(ms = nap((long)(1000 / HZ) + 1)) X { X case 0L: X cnt[0]++; break; X case (((1000 / HZ) ) * 1): X case (((1000 / HZ) + 1) * 1): X cnt[1]++; break; X case (((1000 / HZ) ) * 2): X case (((1000 / HZ) + 1) * 2): X cnt[2]++; break; X case (((1000 / HZ) ) * 3): X case (((1000 / HZ) + 1) * 3): X cnt[3]++; break; X case (((1000 / HZ) ) * 4): X case (((1000 / HZ) + 1) * 4): X cnt[4]++; break; X case (((1000 / HZ) ) * 5): X case (((1000 / HZ) + 1) * 5): X cnt[5]++; break; X case (((1000 / HZ) ) * 6): X case (((1000 / HZ) + 1) * 6): X cnt[6]++; break; X default: X cnt[7]++; break; X } X } X X printf("return value buckets:\n"); X for(itmp = 0; itmp < 7; itmp++) X printf("%d:%d ",(1000/HZ)*itmp,cnt[itmp]); X printf("other:%d\n",cnt[7]); X#endif X exit(0); X X} /* end of main */ X X/* vi: set tabstop=4 shiftwidth=4: */ SHAR_EOF chmod 0644 timetest/naptest.c || echo 'restore of timetest/naptest.c failed' Wc_c="`wc -c < 'timetest/naptest.c'`" test 2342 -eq "$Wc_c" || echo 'timetest/naptest.c: original size 2342, current size' "$Wc_c" rm -f _shar_wnt_.tmp fi # ============= timetest/naptest2.c ============== if test -f 'timetest/naptest2.c' -a X"$1" != X"-c"; then echo 'x - skipping timetest/naptest2.c (File already exists)' rm -f _shar_wnt_.tmp else > _shar_wnt_.tmp echo 'x - extracting timetest/naptest2.c (Text)' sed 's/^X//' << 'SHAR_EOF' > 'timetest/naptest2.c' && X/* CHK=0xD254 */ X/*+------------------------------------------------------------------------- X naptest2.c - nap test suite X wht@n4hgf.Mt-Park.GA.US X XThis test checks a number of nap features. X X1. Does nap correctly nap a reasonable interval of time over X a range of selected periods? X2. Does nap correctly return the period of time it napped? X--------------------------------------------------------------------------*/ X/*+:EDITS:*/ X/*:09-03-1991-21:04-wht@n4hgf-make part of suite */ X/*:06-26-1988-14:05-wht-creation */ X X#include X#include X X/*+------------------------------------------------------------------------- X nap_test(period) - make repeated nap test for 'period' X--------------------------------------------------------------------------*/ Xvoid Xnap_test(period) Xlong period; X{ Xint itmp,zero_nap_count = 0; Xlong total = 0L,msec,then,now,nap(); Xchar s64[64],*ctime(); X#define CNT 500 X X printf("testing nap(%ldL) should take about %.2lf sec\n", X period,(double)period * CNT / 1000.0); X time(&then); X printf(" started at %s",ctime(&then)); X itmp = CNT; X while(itmp--) X { X msec = nap(period); X total += msec; X if(!msec) X zero_nap_count++; X } X time(&now); X strcpy(s64,ctime(&now)); X s64[strlen(s64) - 1] = 0; X printf(" ended at %s (%ld secs)\n",s64,now - then); X printf(" average nap return value = %.2lf msec\n",(double)total / CNT); X printf(" reported zero length nap %d out of %d times\n\n", X zero_nap_count,CNT); X X} /* end of nap_test */ X X/*+------------------------------------------------------------------------- X main(argc,argv,envp) X--------------------------------------------------------------------------*/ Xmain(argc,argv,envp) Xint argc; Xchar **argv; Xchar **envp; X{ X int hz; X long hzmsec; X X setbuf(stdout,NULL); X X/* X * learn tick rate for various timers X */ X if(getenv("HZ")) X hz = atoi(getenv("HZ")); X else X hz = HZ; X hzmsec = (1000 / hz) + 1; /* prevent damaged nap from not napping */ X X nap_test(5L); /* this never naps at all unless accidental X * scheduling causes a delay X */ X X nap_test(hzmsec); X nap_test(50L); X exit(0); X X} /* end of main */ X X/* vi: set tabstop=4 shiftwidth=4: */ SHAR_EOF chmod 0644 timetest/naptest2.c || echo 'restore of timetest/naptest2.c failed' Wc_c="`wc -c < 'timetest/naptest2.c'`" test 2312 -eq "$Wc_c" || echo 'timetest/naptest2.c: original size 2312, current size' "$Wc_c" rm -f _shar_wnt_.tmp fi # ============= timetest/naptest3.c ============== if test -f 'timetest/naptest3.c' -a X"$1" != X"-c"; then echo 'x - skipping timetest/naptest3.c (File already exists)' rm -f _shar_wnt_.tmp else > _shar_wnt_.tmp echo 'x - extracting timetest/naptest3.c (Text)' sed 's/^X//' << 'SHAR_EOF' > 'timetest/naptest3.c' && X/* CHK=0x83DE */ X/*+------------------------------------------------------------------------- X naptest3.c - nap test suite X wht@n4hgf.Mt-Park.GA.US X XThis test attempts to see if small naps nap even though return value is 0, Xthus partially complying with the man page: X"The current process is suspended from execution for at least Xthe number of milliseconds specified by period ...." ^^^^^^^^ X X--------------------------------------------------------------------------*/ X/*+:EDITS:*/ X/*:09-03-1991-20:30-wht@n4hgf-creation */ X X#include X#include X Xmain(argc,argv) Xint argc; Xchar **argv; X{ X int itmp,hz,expected; X char *cptr,*getenv(),*ctime(); X long hzmsec,then,now,actual; X X /* learn tick period */ X if((cptr = getenv("HZ")) && *cptr) X hz = atoi(cptr); X else X hz = HZ; X hzmsec = (1000 / hz) + 1; /* prevent damaged nap from not napping */ X X itmp = 1000; X expected = (int)(hzmsec * itmp / 1000L); X printf("This should sleep about %d seconds, %ld+ msec at a time\n", X expected, hzmsec - 1); X time(&then); X printf("Nap started at %s",ctime(&then)); X while(itmp--) X nap(hzmsec - 1); X time(&now); X printf("Nap ended at %s",ctime(&now)); X printf("Napped about %ld second(s)",actual = now - then); X if(!actual) X printf(", not at all!"); X else if(actual == 1) X printf(". Must be a lucky epoch tick. Try it again!"); X printf("\n",stdout); X X exit(0); X} /* end of main */ SHAR_EOF chmod 0644 timetest/naptest3.c || echo 'restore of timetest/naptest3.c failed' Wc_c="`wc -c < 'timetest/naptest3.c'`" test 1469 -eq "$Wc_c" || echo 'timetest/naptest3.c: original size 1469, current size' "$Wc_c" rm -f _shar_wnt_.tmp fi # ============= timetest/seltest.c ============== if test -f 'timetest/seltest.c' -a X"$1" != X"-c"; then echo 'x - skipping timetest/seltest.c (File already exists)' rm -f _shar_wnt_.tmp else > _shar_wnt_.tmp echo 'x - extracting timetest/seltest.c (Text)' sed 's/^X//' << 'SHAR_EOF' > 'timetest/seltest.c' && X/* CHK=0xF551 */ X/*+------------------------------------------------------------------------- X testsel.c - test timeout interval of select() X wht@n4hgf.Mt-Park.GA.US X--------------------------------------------------------------------------*/ X/*+:EDITS:*/ X/*:09-03-1991-19:57-wht@n4hgf-creation */ X X#include X#ifdef M_SYSV /* SCO */ X#include X#else X#include X#endif X X/*+------------------------------------------------------------------------- X main(argc,argv) X--------------------------------------------------------------------------*/ Xmain(argc,argv) Xint argc; Xchar **argv; X{ Xstruct timeval tv; X X setbuf(stdout,NULL); X X while(1) X { X tv.tv_sec = 0; X tv.tv_usec = 100*1000L; X select(0,0,0,0,&tv); X fputs("100 msec?\n",stdout); X } X X exit(0); X} /* end of main */ X X/* vi: set tabstop=4 shiftwidth=4: */ X/* end of testsel.c */ SHAR_EOF chmod 0644 timetest/seltest.c || echo 'restore of timetest/seltest.c failed' Wc_c="`wc -c < 'timetest/seltest.c'`" test 863 -eq "$Wc_c" || echo 'timetest/seltest.c: original size 863, current size' "$Wc_c" rm -f _shar_wnt_.tmp fi rm -f _shar_seq_.tmp echo You have unpacked the last part exit 0 exit 0 # Just in case...