home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / compsrcs / misc / volume02 / turbocti.mrs < prev    next >
Encoding:
Internet Message Format  |  1991-08-27  |  18.0 KB

  1. From mipos3!omepd!uoregon!hp-pcd!hplabs!decwrl!decvax!ima!necntc!ncoast!allbery Tue Mar  8 19:24:28 PST 1988
  2. Article 322 of comp.sources.misc:
  3. Path: td2cad!mipos3!omepd!uoregon!hp-pcd!hplabs!decwrl!decvax!ima!necntc!ncoast!allbery
  4. From: asjoshi@phoenix.princeton.edu (Amit S. Joshi)
  5. Newsgroups: comp.sources.misc
  6. Subject: v02i069: Timer and CTRL BRK functions in Turbo C
  7. Keywords: Turbo C, timers, ^C
  8. Message-ID: <7472@ncoast.UUCP>
  9. Date: 5 Mar 88 23:26:25 GMT
  10. Sender: allbery@ncoast.UUCP
  11. Reply-To: asjoshi@phoenix.princeton.edu (Amit S. Joshi)
  12. Organization: Princeton University, NJ
  13. Lines: 637
  14. Approved: allbery@ncoast.UUCP
  15. Comp.sources.misc: Volume 2, Issue 69
  16. Submitted-By: "Amit S. Joshi" <asjoshi@phoenix.princeton.edu>
  17. Archive-Name: turbo-C-timers
  18.  
  19. Comp.sources.misc: Volume 2, Issue 69
  20. Submitted-By: "Amit S. Joshi" <asjoshi@phoenix.princeton.edu>
  21. Archive-Name: turbo-C-timers
  22.  
  23. [*Another* ARCed source?!  Egads!  ++bsa]
  24.  
  25. Here are a set of four functions to handle timers and ^C breaks slightly
  26. more easily from Turbo C. Includes a small 'manual' page to use the
  27. functions. Could be ported to MSC (but I don't have that expensive
  28. compiler  ;-). For some reason the functions cause a stack overflow in
  29. the small, tiny and medium models. There is a small test program to
  30. excercise the timer functions included. Also included is the makefile
  31. and the default rules file. I used NDMAKE.
  32.  
  33. UUdecode and then unarchive. Any old arc program (even tthe UNIX ones)
  34. should be able to do it.
  35.  
  36. [Not any more; it's now a shar.  ++bsa]
  37.  
  38. ----- cut above this line -----
  39. #! /bin/sh
  40. #
  41. # This is a shell archive.  Save this into a file, edit it
  42. # and delete all lines above this comment.  Then give this
  43. # file to sh by executing the command "sh file".  The files
  44. # will be extracted into the current directory owned by
  45. # you with default permissions.
  46. #
  47. # The files contained herein are:
  48. #
  49. # -rw-r--r--   1 allbery  System      1622 Feb 27 00:55 MAKE.INI
  50. # -rw-r--r--   1 allbery  System      1129 Mar  4 15:01 MAKEFILE
  51. # -rw-r--r--   1 allbery  System      1574 Mar  4 15:37 TEST.C
  52. # -rw-r--r--   1 allbery  System      5556 Feb 25 12:35 TICK.C
  53. # -rw-r--r--   1 allbery  System      2511 Mar  4 14:56 TICK.DOC
  54. # -rw-r--r--   1 allbery  System      1442 Feb 25 11:49 TICK.H
  55. #
  56. echo 'x - MAKE.INI'
  57. if test -f MAKE.INI; then echo 'shar: not overwriting MAKE.INI'; else
  58. sed 's/^X//' << '________This_Is_The_END________' > MAKE.INI
  59. X#    rules especially for the Turbo C package.
  60. X
  61. XCC=tcc
  62. XAS=masm
  63. XLB=lib
  64. XCPP=cpp
  65. XLINK=tlink
  66. XMODEL=s
  67. X
  68. XLIB=c:\turboc\lib
  69. XINCLUDE=c:\turboc\include
  70. X
  71. XLIBS=
  72. XSTDLIBFILES=$(LIB)\math$(MODEL) $(LIB)\c$(MODEL) $(LIB)\fp87 
  73. XSTDOBJFILES=$(LIB)\c0$(MODEL) 
  74. X
  75. X
  76. XTCFLAGS=-DTURBOC -m$(MODEL) 
  77. XASFLAGS=/E
  78. XLFLAGS=/d
  79. XCFLAGS=
  80. X
  81. X.SUFFIXES: .i .com .exe .obj .asm .c .for .pas
  82. X
  83. X# create response files for tlink too.
  84. X.RESPONSE_LINK:    tlink
  85. X
  86. X#    ASM -> EXE using masm and tlink
  87. X.asm.exe:
  88. X    $(AS) $<;
  89. X    $(LINK) $(STDOBJFILES) $*,$*,,$(STDLIBFILES) $(LFLAGS) 
  90. X    @rm -f $*.obj
  91. X
  92. X#    ASM -> OBJ using MASM
  93. X.asm.obj:
  94. X    $(AS) $<;
  95. X
  96. X#    C -> ASM using tcc -S option
  97. X.c.asm:
  98. X    $(CC) $(TCFLAGS) -S $(CFLAGS) -I$(INCLUDE) -L$(LIB) $(LIBS) $<
  99. X    @tcod $*
  100. X    @mv $*.cod $*.asm
  101. X
  102. X#    C -> COM using tcc and then exe2bin
  103. X.c.com:
  104. X    $(CC) $(TCFLAGS) $(CFLAGS) -I$(INCLUDE) -L$(LIB) $(LIBS) $<
  105. X    -(@exe2bin $*.exe $*.com)
  106. X    @rm -f $*.obj $*.exe
  107. X
  108. X#    C -> EXE using tcc ; use this since it is faster than C -> OBJ -> EXE
  109. X.c.exe:
  110. X    $(CC) $(TCFLAGS) $(CFLAGS) -I$(INCLUDE) -L$(LIB) $(LIBS) $<
  111. X    @rm -fi- $*.obj
  112. X
  113. X#    C -> OBJ using tcc -c option
  114. X.c.obj:
  115. X    $(CC) $(TCFLAGS) -c $(CFLAGS) -I$(INCLUDE) -L$(LIB) $(LIBS) $<
  116. X
  117. X#    OBJ -> EXE using tcc 
  118. X.obj.exe:
  119. X    $(CC) $(TCFLAGS) $(CFLAGS) -I$(INCLUDE) -L$(LIB) $(LIBS) $<
  120. X
  121. X#    EXE -> COM using exe2bin
  122. X.exe.com:
  123. X    exe2bin $< $*.com
  124. X    @rm -f $*.exe
  125. X
  126. X#    C -> I run preprocessor only
  127. X.c.i:
  128. X    $(CPP) $(TCFLAGS) -P $(CFLAGS) -I$(INCLUDE) -L$(LIB) $(LIBS) $<
  129. X
  130. X#    cleans the current directory - always needed
  131. Xclean:;    @rm -f *.bak *.map *.lst
  132. X
  133. X#    make makefile using mkmf interactively
  134. ________This_Is_The_END________
  135. if test `wc -l < MAKE.INI` -ne 75; then
  136.     echo 'shar: MAKE.INI was damaged during transit (should have been 75 bytes)'
  137. fi
  138. fi        ; : end of overwriting check
  139. echo 'x - MAKEFILE'
  140. if test -f MAKEFILE; then echo 'shar: not overwriting MAKEFILE'; else
  141. sed 's/^X//' << '________This_Is_The_END________' > MAKEFILE
  142. X
  143. XMODEL    = ml
  144. X#    turn optimization on by default
  145. XCFLAGS        = -O
  146. X
  147. XDEST          = .
  148. X
  149. XEXTHDRS          = /turboc/include/dos.h \
  150. X        /turboc/include/stdarg.h \
  151. X        /turboc/include/stdio.h \
  152. X        /turboc/include/stdlib.h
  153. X
  154. XHDRS          = TICK.H
  155. X
  156. XLIBS          = 
  157. X
  158. XMAKEFILE      = makefile
  159. X
  160. XOBJS          = TEST.OBJ \
  161. X        TICK.OBJ
  162. X
  163. X#    Print over the ethernet
  164. XPRINT          = eprint
  165. X
  166. XPROGRAM          = test.exe
  167. X
  168. XSRCS          = TEST.C \
  169. X        TICK.C
  170. X
  171. Xall:        $(PROGRAM)
  172. X
  173. X$(PROGRAM):     $(OBJS) $(LIBS)
  174. X        $(LINK) $(STDOBJFILES) $(OBJS),$@,,$(LIBS) $(STDLIBFILES)
  175. X
  176. Xclean:;    rm -f *.bak *.lst *.map $(OBJS) 
  177. X
  178. Xdepend:;    @mkmf -f $(MAKEFILE) PROGRAM=$(PROGRAM) DEST=$(DEST)
  179. X
  180. Xinstall:    $(PROGRAM)
  181. X        @mv $(PROGRAM) $(DEST)
  182. X
  183. Xprint:;        $(PRINT) $(HDRS) $(SRCS)
  184. X
  185. Xprogram:        $(PROGRAM)
  186. X
  187. Xupdate:        $(DEST)/$(PROGRAM)
  188. X
  189. X$(DEST)/$(PROGRAM): $(SRCS) $(LIBS) $(HDRS) $(EXTHDRS)
  190. X        @make -f $(MAKEFILE) DEST=$(DEST) install
  191. X###
  192. XTEST.OBJ: /turboc/include/stdio.h /turboc/include/stdarg.h tick.h \
  193. X    /turboc/include/dos.h
  194. XTICK.OBJ: /turboc/include/stdlib.h /turboc/include/stdio.h \
  195. X    /turboc/include/stdarg.h tick.h /turboc/include/dos.h
  196. ________This_Is_The_END________
  197. if test `wc -l < MAKEFILE` -ne 54; then
  198.     echo 'shar: MAKEFILE was damaged during transit (should have been 54 bytes)'
  199. fi
  200. fi        ; : end of overwriting check
  201. echo 'x - TEST.C'
  202. if test -f TEST.C; then echo 'shar: not overwriting TEST.C'; else
  203. sed 's/^X//' << '________This_Is_The_END________' > TEST.C
  204. X/*    test.c - gently excersise the tick.c functions */
  205. X
  206. X#include <stdio.h>
  207. X#include "tick.h"
  208. X
  209. X#define    NT 300
  210. X#define ND 5
  211. X
  212. Xvoid test1(void) {
  213. X    printf("1");
  214. X}
  215. X
  216. Xvoid test2(void) {
  217. X    putc('a',stderr);
  218. X}
  219. X
  220. Xmain() {
  221. X    int i;
  222. X    void test1(), test2();
  223. X    
  224. X    for (i = NT; i > 0; i--) {
  225. X        test1(); test2();
  226. X        delay(ND);
  227. X    }
  228. X    
  229. X    if ((i = install_timer(test1)) != 0) {
  230. X        printf("Install_timer failed: %d\n",i);
  231. X        exit(1);
  232. X    }
  233. X    
  234. X    printf("\nInstalled timer 1\n");
  235. X    
  236. X    for (i = NT; i > 0; i--) delay(ND);
  237. X    
  238. X    if ((i = install_timer(test2)) != 0) {
  239. X        printf("Install_timer failed: %d\n",i);
  240. X        exit(1);
  241. X    }
  242. X    
  243. X    printf("\nInstalled timer 2\n");
  244. X    
  245. X    for (i = NT; i > 0; i--) delay(ND);
  246. X    
  247. X    if ((i = remove_timer(test2)) != 0) {
  248. X        printf("Remove timer failed: %d\n",i);
  249. X        exit(1);
  250. X    }
  251. X    printf("\nRemoved timer 2\n");
  252. X    for (i = NT; i > 0; i--) delay(ND);
  253. X    if ((i = install_timer(test2)) != 0) {
  254. X        printf("Install_timer failed: %d\n",i);
  255. X        exit(1);
  256. X    }
  257. X    
  258. X    printf("\nInstalled timer 2\n");
  259. X    
  260. X    for (i = NT; i > 0; i--) delay(ND);
  261. X    if ((i = remove_timer(test1)) != 0) {
  262. X        printf("Remove timer failed: %d\n",i);
  263. X        exit(1);
  264. X    }
  265. X    printf("\nRemoved timer 1\n");
  266. X    for (i = NT; i > 0; i--) delay(ND);
  267. X
  268. X    if ((i = install_timer(test1)) != 0) {
  269. X        printf("Install_timer failed: %d\n",i);
  270. X        exit(1);
  271. X    }
  272. X    
  273. X    printf("\nInstalled timer 1\n");
  274. X    for (i = NT; i > 0; i--) delay(ND);
  275. X    
  276. X    if ((i = remove_timer(NULLVFP)) != 0) {
  277. X        printf("Remove timer failed: %d\n",i);
  278. X        exit(1);
  279. X    }
  280. X    printf("\nRemoved all timers\n");
  281. X    for (i = NT; i < 0; i--) delay(ND);
  282. X}
  283. X    
  284. ________This_Is_The_END________
  285. if test `wc -l < TEST.C` -ne 80; then
  286.     echo 'shar: TEST.C was damaged during transit (should have been 80 bytes)'
  287. fi
  288. fi        ; : end of overwriting check
  289. echo 'x - TICK.C'
  290. if test -f TICK.C; then echo 'shar: not overwriting TICK.C'; else
  291. sed 's/^X//' << '________This_Is_The_END________' > TICK.C
  292. X/*    tick.c - installs a function which is called every clock tick */
  293. X/*    (c) - Amit Joshi, Princeton University 
  294. X
  295. X    This code may be used freely for any noncommercial use. It may NOT
  296. X    be used in any commercial package without written permission from
  297. X    the author. This clause is to protect me from legal hassles with
  298. X    the university about code developed here. This code is supplied
  299. X    "AS IS" i.e. with no warranty. Do not remove this notice. Any 
  300. X    modifications should be clearly noted before redistribution.
  301. X**/
  302. X
  303. X/**    Amit Joshi
  304. X    MAE Dept., Engg. Quad.
  305. X    Princeton University
  306. X    December 1987
  307. X**/
  308. X
  309. X/**             
  310. X    The __tick__() and dosbusy() functions have been stolen from the
  311. X    "rdir.c" code by Dean D. McCrory. The __tick__() has been 
  312. X    rewritten (and renamed from timer_handler()) to be more general.
  313. X    Amit Joshi
  314. X    January 1988
  315. X**/
  316. X
  317. X#include <stdlib.h>
  318. X#include <stdio.h>
  319. X#include "tick.h"
  320. X
  321. X/* Stuff for to handle the ctrl break functions */
  322. Xstatic int __nc_brks = 0;
  323. Xstatic char __abort = 1;
  324. Xstatic void (* __c_brks[NCBRKS])();
  325. X
  326. X/* Stuff to run timers */
  327. Xstatic void interrupt (* __otimer)() = NULLIVFP;
  328. Xstatic int __ntimers = 0;
  329. Xstatic void (* __timers[NTIMERS])();
  330. Xstatic char far * dosbusy_fl;    /* dos maintains this */
  331. X
  332. X/* The functions used in this file */
  333. Xstatic int __cbrk(void);
  334. Xstatic void __clean_timer(void);
  335. Xstatic void interrupt __tick__(void);
  336. Xstatic char far * getdosbusy(void);
  337. X
  338. Xstatic int
  339. X__cbrk(void) {
  340. X    int nf;
  341. X    
  342. X    if (!abort) {
  343. X        for (nf = 0; nf < __nc_brks; ++nf)
  344. X            (* __c_brks[nf])();
  345. X        exit(1);
  346. X    } else return 1;
  347. X}
  348. X
  349. Xstatic void
  350. X__clean_timer(void) {
  351. X    if (__otimer == NULLIVFP) return;     /* nothing set yet */
  352. X    setvect(TIMER_INT,__otimer);
  353. X}
  354. X
  355. X/* __tick__ ()
  356. X *
  357. X * This function intercepts the hardware timer interrupt.  It checks the
  358. X * dosbusy flag and runs through a list of timer driven functions if safe 
  359. X * to do so.
  360. X */    
  361. X
  362. Xstatic void interrupt
  363. X__tick__(void)
  364. X{
  365. X   static int in_fl = 0;
  366. X   int timer;
  367. X
  368. X   /* if the following statement is NOT coded, the 8259 blocks all hardware
  369. X      interrupts including the keyboard interrupt.  Since we wait for a key
  370. X      in list_directory (), this causes the PC to lock up.  This one took
  371. X      a while to figure out */
  372. X   outportb (0x20, 0x20);        /* send eoi to 8259 */
  373. X   (*__otimer) ();           /* chain to previous timer handler */
  374. X   
  375. X   if (! in_fl)
  376. X      {
  377. X      in_fl = 1;                 /* we are in our ISR */
  378. X         if (! *dosbusy_fl ) 
  379. X         /* run through the list of timers */
  380. X         for (timer = 0; timer < __ntimers; ++timer)
  381. X             if (__timers[timer] != NULLVFP)  
  382. X                 (* __timers[timer])();
  383. X      in_fl = 0;
  384. X      }
  385. X   return;                    /* return from ISR */
  386. X}
  387. X
  388. X/* getdosbusy ()
  389. X *
  390. X * Gets the Dos busy flag through interrupt 34h.  This Dos function returnes
  391. X * the busy flag address in es:bx.  This is an UNDOCUMENTED feature of Dos,
  392. X * however it has worked in Dos versions 2.11 - 3.30 for me - Dean McCrory.
  393. X */
  394. Xstatic char far * 
  395. Xgetdosbusy (void)
  396. X{
  397. X   struct SREGS sregs;        /* segment registers */
  398. X   union REGS regs;           /* normal registers */
  399. X
  400. X   regs.h.ah = 0x34;          /* get dos busy flag address (UNDOCUMENTED) */
  401. X   intdosx (®s, ®s, &sregs);
  402. X   return (MK_FP (sregs.es, regs.x.bx));
  403. X}
  404. X
  405. Xint
  406. Xinstall_timer(void (*func)(void))
  407. X{    
  408. X    int i = 0;
  409. X    void __clean_timer();
  410. X    void interrupt __tick__();
  411. X    
  412. X    /* check if the function is already installed */
  413. X
  414. X    if (!__ntimers) {
  415. X        __otimer = getvect(TIMER_INT);
  416. X        /* Get address of DOS busy flag. */
  417. X        dosbusy_fl = getdosbusy();
  418. X        if (atexit(__clean_timer)) return 2;
  419. X        install_cbrk(NULLVFP);
  420. X        setvect(TIMER_INT,__tick__);
  421. X    }
  422. X    /* are we already installed ? */
  423. X    for (i=0; i < __ntimers; i++) 
  424. X        if (__timers[i] == func) return 0;
  425. X    /* enough space for another function ? */
  426. X    if (__ntimers >= NTIMERS) return 1;
  427. X    __timers[__ntimers++] = func;
  428. X    return 0;
  429. X}
  430. X
  431. Xint
  432. Xremove_timer(void (*func)(void))
  433. X{
  434. X    int i = 0;
  435. X    
  436. X    if (func == NULLVFP) {
  437. X        __clean_timer();
  438. X        __ntimers = 0;
  439. X        return 0;
  440. X    }
  441. X    
  442. X    if (!__ntimers) return 1;    /* No timers return func not there */
  443. X    
  444. X    do {
  445. X        /* have we found the function ? */
  446. X        if (__timers[i] == func) { 
  447. X            /* is it the last one in the chain ? */
  448. X            if (i++ == __ntimers) {
  449. X                __timers[i-1] = NULLVFP;
  450. X            } else {
  451. X                /* move the chain backwards */
  452. X                do { 
  453. X                    __timers[i-1] = __timers[i]; i++; 
  454. X                } while(i <= __ntimers);
  455. X            }            
  456. X            __ntimers--;
  457. X            return 0;
  458. X        } else i++;
  459. X    } while (i < __ntimers);
  460. X    return 1;
  461. X}
  462. X
  463. Xint
  464. Xinstall_cbrk (void (* func)(void))
  465. X{
  466. X    int i = 0;
  467. X
  468. X
  469. X    
  470. X    if (!__nc_brks) {
  471. X        setcbrk(1);    /* ensure that ctrl break is enabled */
  472. X        ctrlbrk(__cbrk);
  473. X        __abort = 1;
  474. X    }
  475. X    
  476. X    if (func == NULLVFP) __abort = 1;
  477. X    
  478. X    for (i = 0; i < __nc_brks; i++)
  479. X        if (__c_brks[i] == func) return 0;
  480. X    /* enough space for another function ? */
  481. X    if (__nc_brks >= NCBRKS) return 1;
  482. X    __c_brks[__nc_brks++] = func;
  483. X    return 0;
  484. X}
  485. X
  486. Xint
  487. Xremove_cbrk (void (* func)(void))
  488. X{
  489. X    int i = 0;
  490. X    
  491. X    if (func == NULLVFP) __abort = 0;
  492. X    
  493. X    if (!__nc_brks) return 1;    /* No timers return func not there */
  494. X    
  495. X    do {
  496. X        /* have we found the function ? */
  497. X        if (__c_brks[i] == func) { 
  498. X            /* is it the last one in the chain ? */
  499. X            if (i++ == __nc_brks) {
  500. X                __c_brks[i-1] = NULLVFP;
  501. X            } else {
  502. X                /* move the chain backwards */
  503. X                do { 
  504. X                    __c_brks[i-1] = __c_brks[i]; i++; 
  505. X                } while(i <= __nc_brks);
  506. X            }            
  507. X            __nc_brks--;
  508. X            return 0;
  509. X        } else i++;
  510. X    } while (i < __nc_brks);
  511. X    return 1;
  512. ________This_Is_The_END________
  513. if test `wc -l < TICK.C` -ne 220; then
  514.     echo 'shar: TICK.C was damaged during transit (should have been 220 bytes)'
  515. fi
  516. fi        ; : end of overwriting check
  517. echo 'x - TICK.DOC'
  518. if test -f TICK.DOC; then echo 'shar: not overwriting TICK.DOC'; else
  519. sed 's/^X//' << '________This_Is_The_END________' > TICK.DOC
  520. XAll the functions in this file make heavy use of TurboC and PCDOS
  521. Xfacilities and are not portable. 
  522. X
  523. XWARNING:
  524. X    DO NOT compile with tiny, small or medium models. Stack overflow
  525. X    occurs and if the stack checking option of the compiler is used
  526. X    then the timers are not unloaded and the system crashes - in fact
  527. X    you have to setup the entire system from scratch.
  528. X        
  529. XUSAGE:
  530. X    #include "tick.h"
  531. X
  532. X    int install_timer(vod (*func());
  533. X        Installs the function "func()" to be called EVERY tick. 
  534. X        Removes the function on exit from the program - both if
  535. X        ^C or normal. You MUST NOT use the Turbo C supplied
  536. X        ctrlbrk() function if you use this one. Use
  537. X        "install_cbrk()" instead.
  538. X
  539. X    int install_cbrk(void (*func)());
  540. X        Installs the function "func()" to be called when ^C is hit.
  541. X        You can chain a series of functions. If you use this DO NOT
  542. X        use the Turbo C supplied ctrlbrk(). If argument is NULLVFP
  543. X        ^C exits from the program.
  544. X
  545. X    int remove_timer(void (*func)());
  546. X        Removes "func()" from timer list. If NULLVFP is given as an
  547. X        argument all timers are cleaned.
  548. X
  549. X    int remove_cbrk(void (*func)());
  550. X        Removes "func()" from ctrlbrk list. If argument    is NULLVFP
  551. X        ^C has no action.
  552. XRETURN VALUES:
  553. X    0 => function was successfully installed or removed.
  554. X    1 => Install failed because of lack of space. Compile again with a
  555. X         larger NTIMER or NCBRK in "tick.h"
  556. X         Remove  failed because function not found.
  557. X    2 => Install timer failed because we could not hook timer cleaner 
  558. X         onto atexit(). Try again with fewer atexit() functions.
  559. X
  560. XNOTES:
  561. X    * DO NOT use the Turbo C ctrlbrk() function if using these functions
  562. X      - it can have quite disasterous effects. Use install_cbrk() - it 
  563. X      is more general in any case !.
  564. X    * Both the install functions try to check if the function is already
  565. X      present and do not duplicate installations.
  566. X    * Define HARDTIMER in "tick.h" if you want to use the hardware 
  567. X      interrupt rather than the DOS 'soft' interrupt. This is at your own
  568. X      peril. I have not used this.
  569. X
  570. XBUGS:
  571. X    Notify all bugs to :
  572. X        Q3696@PUCC.BITNET or
  573. X        {seismo, rutgers}\!princeton\!phoenix\!asjoshi
  574. X
  575. XACKNOWLEDGEMENTS:
  576. X    Dean D. McCrory for two functions which really form the heart of the 
  577. X    timer portion : timer_handler, and dosbusy. The first has been 
  578. X    modified and made more general. It is also renamed to __tick__().
  579. X    The rest of the code was written using Turbo C v1.5 entirely by me
  580. X    Thanks to Borland for the wonderful (and inexpensive) C compiler.
  581. X
  582. ________This_Is_The_END________
  583. if test `wc -l < TICK.DOC` -ne 62; then
  584.     echo 'shar: TICK.DOC was damaged during transit (should have been 62 bytes)'
  585. fi
  586. fi        ; : end of overwriting check
  587. echo 'x - TICK.H'
  588. if test -f TICK.H; then echo 'shar: not overwriting TICK.H'; else
  589. sed 's/^X//' << '________This_Is_The_END________' > TICK.H
  590. X/*    tick.h - the include file for timer and c_brk function installation */
  591. X/*    (c) - Amit Joshi, Princeton University 
  592. X
  593. X    This code may be used freely for any noncommercial use. It may NOT
  594. X    be used in any commercial package without written permission from
  595. X    the author. This clause is to protect me from legal hassles with
  596. X    the university about code developed here. This code is supplied
  597. X    "AS IS" i.e. with no warranty. Do not remove this notice. Any 
  598. X    modifications should be clearly noted before redistribution.
  599. X**/
  600. X
  601. X/**    Amit Joshi
  602. X    MAE Dept., Engg. Quad.
  603. X    Princeton University
  604. X    December 1987
  605. X**/
  606. X
  607. X/**
  608. X    Change the values defined for NTIMERS and NCBRKS to increase 
  609. X    number of timer and cbrk functions installed.
  610. X
  611. X    Amit Joshi
  612. X    January 1988
  613. X**/
  614. X
  615. X#ifndef    __TICK_H__
  616. X#define    __TICK_H__
  617. X
  618. X#include <dos.h>
  619. X
  620. X/* Change the following definitions to increase number of timers and cbrks */
  621. X#define    NTIMERS    2    /* number of timers installable */
  622. X#define    NCBRKS    2    /* number of cbrks installable */
  623. X
  624. X#define NULLIVFP    (void interrupt (*)())NULL
  625. X#define    NULLVFP        (void (*)())NULL
  626. X#define NULLFP        (int (*)())NULL 
  627. X
  628. X#ifdef    HARDTIMER
  629. X#define    TIMER_INT    0x08
  630. X#else
  631. X#define TIMER_INT    0x1C     
  632. X#endif
  633. X
  634. X/* user callable functions */
  635. Xint    _Cdecl        install_timer(void (*func)());    
  636. Xint    _Cdecl        install_cbrk(void (*func)());
  637. Xint    _Cdecl        remove_timer(void (*func)());
  638. Xint    _Cdecl        remove_cbrk(void (*func)());
  639. X
  640. X#endif    __TICK_H__
  641. ________This_Is_The_END________
  642. if test `wc -l < TICK.H` -ne 51; then
  643.     echo 'shar: TICK.H was damaged during transit (should have been 51 bytes)'
  644. fi
  645. fi        ; : end of overwriting check
  646. exit 0
  647. ---- cut below this line -----
  648.  
  649. Amit Joshi    BITNET    |    Q3696@PUCC.BITNET
  650.         USENET    | {seismo, rutgers}\!princeton\!phoenix\!asjoshi
  651. "There's a pleasure in being mad... which none but madmen know!" - St.Dryden
  652. -- 
  653. Amit Joshi    BITNET    |    Q3696@PUCC.BITNET
  654.         USENET    | {seismo, rutgers}\!princeton\!phoenix\!asjoshi
  655. "There's a pleasure in being mad... which none but madmen know!" - St.Dryden
  656.  
  657.  
  658.