Back to index

lightning-sunbird  0.9+nobinonly
prinrval.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is the Netscape Portable Runtime (NSPR).
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998-2000
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either the GNU General Public License Version 2 or later (the "GPL"), or
00026  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 /*
00039 ** File:             prinrval.h
00040 ** Description:      API to interval timing functions of NSPR.
00041 **
00042 **
00043 ** NSPR provides interval times that are independent of network time
00044 ** of day values. Interval times are (in theory) accurate regardless
00045 ** of host processing requirements and also very cheap to acquire. It
00046 ** is expected that getting an interval time while in a synchronized
00047 ** function (holding one's lock).
00048 **/
00049 
00050 #if !defined(prinrval_h)
00051 #define prinrval_h
00052 
00053 #include "prtypes.h"
00054 
00055 PR_BEGIN_EXTERN_C
00056 
00057 /**********************************************************************/
00058 /************************* TYPES AND CONSTANTS ************************/
00059 /**********************************************************************/
00060 
00061 typedef PRUint32 PRIntervalTime;
00062 
00063 /***********************************************************************
00064 ** DEFINES:     PR_INTERVAL_MIN
00065 **              PR_INTERVAL_MAX
00066 ** DESCRIPTION:
00067 **  These two constants define the range (in ticks / second) of the
00068 **  platform dependent type, PRIntervalTime. These constants bound both
00069 **  the period and the resolution of a PRIntervalTime. 
00070 ***********************************************************************/
00071 #define PR_INTERVAL_MIN 1000UL
00072 #define PR_INTERVAL_MAX 100000UL
00073 
00074 /***********************************************************************
00075 ** DEFINES:     PR_INTERVAL_NO_WAIT
00076 **              PR_INTERVAL_NO_TIMEOUT
00077 ** DESCRIPTION:
00078 **  Two reserved constants are defined in the PRIntervalTime namespace.
00079 **  They are used to indicate that the process should wait no time (return
00080 **  immediately) or wait forever (never time out), respectively.
00081 ***********************************************************************/
00082 #define PR_INTERVAL_NO_WAIT 0UL
00083 #define PR_INTERVAL_NO_TIMEOUT 0xffffffffUL
00084 
00085 /**********************************************************************/
00086 /****************************** FUNCTIONS *****************************/
00087 /**********************************************************************/
00088 
00089 /***********************************************************************
00090 ** FUNCTION:    PR_IntervalNow
00091 ** DESCRIPTION:
00092 **  Return the value of NSPR's free running interval timer. That timer
00093 **  can be used to establish epochs and determine intervals (be computing
00094 **  the difference between two times).
00095 ** INPUTS:      void
00096 ** OUTPUTS:     void
00097 ** RETURN:      PRIntervalTime
00098 **  
00099 ** SIDE EFFECTS:
00100 **  None
00101 ** RESTRICTIONS:
00102 **  The units of PRIntervalTime are platform dependent. They are chosen
00103 **  such that they are appropriate for the host OS, yet provide sufficient
00104 **  resolution and period to be useful to clients. 
00105 ** MEMORY:      N/A
00106 ** ALGORITHM:   Platform dependent
00107 ***********************************************************************/
00108 NSPR_API(PRIntervalTime) PR_IntervalNow(void);
00109 
00110 /***********************************************************************
00111 ** FUNCTION:    PR_TicksPerSecond
00112 ** DESCRIPTION:
00113 **  Return the number of ticks per second for PR_IntervalNow's clock.
00114 **  The value will be in the range [PR_INTERVAL_MIN..PR_INTERVAL_MAX].
00115 ** INPUTS:      void
00116 ** OUTPUTS:     void
00117 ** RETURN:      PRUint32
00118 **  
00119 ** SIDE EFFECTS:
00120 **  None
00121 ** RESTRICTIONS:
00122 **  None
00123 ** MEMORY:      N/A
00124 ** ALGORITHM:   N/A
00125 ***********************************************************************/
00126 NSPR_API(PRUint32) PR_TicksPerSecond(void);
00127 
00128 /***********************************************************************
00129 ** FUNCTION:    PR_SecondsToInterval
00130 **              PR_MillisecondsToInterval
00131 **              PR_MicrosecondsToInterval
00132 ** DESCRIPTION:
00133 **  Convert standard clock units to platform dependent intervals.
00134 ** INPUTS:      PRUint32
00135 ** OUTPUTS:     void
00136 ** RETURN:      PRIntervalTime
00137 **  
00138 ** SIDE EFFECTS:
00139 **  None
00140 ** RESTRICTIONS:
00141 **  Conversion may cause overflow, which is not reported.
00142 ** MEMORY:      N/A
00143 ** ALGORITHM:   N/A
00144 ***********************************************************************/
00145 NSPR_API(PRIntervalTime) PR_SecondsToInterval(PRUint32 seconds);
00146 NSPR_API(PRIntervalTime) PR_MillisecondsToInterval(PRUint32 milli);
00147 NSPR_API(PRIntervalTime) PR_MicrosecondsToInterval(PRUint32 micro);
00148 
00149 /***********************************************************************
00150 ** FUNCTION:    PR_IntervalToSeconds
00151 **              PR_IntervalToMilliseconds
00152 **              PR_IntervalToMicroseconds
00153 ** DESCRIPTION:
00154 **  Convert platform dependent intervals to standard clock units.
00155 ** INPUTS:      PRIntervalTime
00156 ** OUTPUTS:     void
00157 ** RETURN:      PRUint32
00158 **  
00159 ** SIDE EFFECTS:
00160 **  None
00161 ** RESTRICTIONS:
00162 **  Conversion may cause overflow, which is not reported.
00163 ** MEMORY:      N/A
00164 ** ALGORITHM:   N/A
00165 ***********************************************************************/
00166 NSPR_API(PRUint32) PR_IntervalToSeconds(PRIntervalTime ticks);
00167 NSPR_API(PRUint32) PR_IntervalToMilliseconds(PRIntervalTime ticks);
00168 NSPR_API(PRUint32) PR_IntervalToMicroseconds(PRIntervalTime ticks);
00169 
00170 PR_END_EXTERN_C
00171 
00172 
00173 #endif /* !defined(prinrval_h) */
00174 
00175 /* prinrval.h */