home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume2 / turbo-C-timers < prev    next >
Internet Message Format  |  1991-08-07  |  18KB

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