home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / exampleCode / MP / timer / highres / second.c < prev   
Encoding:
C/C++ Source or Header  |  1994-08-02  |  1.6 KB  |  51 lines

  1. /*
  2.  * Copyright 1993, 1994, Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  */
  17. #include <sys/types.h>
  18. #include <sys/stat.h>
  19. #include <sys/mman.h>
  20. #include <fcntl.h>
  21. #include <sys/IP5.h>
  22. extern int errno;
  23. unsigned *clockaddr;
  24. /*****************************************************************************/
  25. double io3clock()
  26. {
  27.     static int first = 1;
  28.     int filed;
  29.     if (first) {
  30.         first = 0;
  31.         /* Open memory special device */
  32.         if ( (filed = open("/dev/mmem",O_RDONLY)) == -1) {
  33.             perror ("ERROR in open"); exit(errno);
  34.         }
  35.         /* Map high resolution clock to user space */
  36.         if ( ((int)(clockaddr = mmap(0, 8, PROT_READ, MAP_PRIVATE, filed, IOTIMER_ADDR))) == -1) {
  37.             perror ("ERROR in mmap"); exit(errno);
  38.         }
  39.     }
  40.     return ((double)(*clockaddr)/ 16.0 * 1.e-6);
  41. }
  42. double io3clock_()
  43. {
  44.     return (io3clock());
  45. }
  46.  
  47. double second_()
  48. {
  49.     return (io3clock());
  50. }
  51.