# time.h

    00001 /**************************************************************************************
    00002  Copyright (c) 2002 The UbixOS Project
    00003  All rights reserved.
    00004
    00005 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
    00006
    00007 Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors.
    00008 Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors
    00009 in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its
    00010 contributors may be used to endorse or promote products derived from this software without specific prior written permission.
    00011
    00012 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
    00013 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    00014 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
    00015 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
    00016 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
    00017 OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
    00018 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    00019
    00020  $Id$
    00021
    00022 **************************************************************************************/
    00023
    00024 #ifndef _TIME_H
    00025 #define _TIME_H
    00026
    00027 #include <ubixos/types.h>
    00028 #include <sys/io.h>
    00029
    00030 typedef long suseconds_t;
    00031
    00032 #define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10)
    00033
    00034 #define MINUTE 60
    00035 #define HOUR (60*MINUTE)
    00036 #define DAY (24*HOUR)
    00037 #define YEAR (365*DAY)
    00038
    00039 #ifndef _TIME_T_DECLARED
    00040 typedef __time_t        time_t;
    00041 #define _TIME_T_DECLARED
    00042 #endif
    00043
    00044 struct timespec {
    00045         time_t  tv_sec;         /* seconds */
    00046         long    tv_nsec;        /* and nanoseconds */
    00047 };
    00048
    00049
    00050
    00051 struct timeStruct {
    00052   int sec;
    00053   int min;
    00054   int hour;
    00055   int day;
    00056   int mon;
    00057   int year;
    00058   };
    00059
    00060
    00061 struct timezone {
    00062   int     tz_minuteswest; /* minutes west of Greenwich */
    00063   int     tz_dsttime;     /* type of dst correction */
    00064   };
    00065
    00066 struct timeval {
    00067   long            tv_sec;         /* seconds (XXX should be time_t) */
    00068   suseconds_t     tv_usec;        /* and microseconds */
    00069   };
    00070
    00071 int gettimeofday(struct timeval *tp,struct timezone *tzp);
    00072
    00073
    00074
    00075 int timeInit();
    00076 int timeCmosRead(int);
    00077 uInt32 timeMake(struct timeStruct *time);
    00078
    00079 #endif
    00080
    00081 /***
    00082  END
    00083  ***/
    00084