Home | History | Annotate | Download | only in scriptc
      1 /*
      2  * Copyright (C) 2011 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 /** @file rs_time.rsh
     18  *  \brief RenderScript time routines
     19  *
     20  *  This file contains RenderScript functions relating to time and date
     21  *  manipulation.
     22  */
     23 
     24 #ifndef __RS_TIME_RSH__
     25 #define __RS_TIME_RSH__
     26 
     27 /**
     28  * Calendar time interpreted as seconds elapsed since the Epoch (00:00:00 on
     29  * January 1, 1970, Coordinated Universal Time (UTC)).
     30  */
     31 #ifndef __LP64__
     32 typedef int rs_time_t;
     33 #else
     34 typedef long rs_time_t;
     35 #endif
     36 
     37 /**
     38  * Data structure for broken-down time components.
     39  *
     40  * tm_sec   - Seconds after the minute. This ranges from 0 to 59, but possibly
     41  *            up to 60 for leap seconds.
     42  * tm_min   - Minutes after the hour. This ranges from 0 to 59.
     43  * tm_hour  - Hours past midnight. This ranges from 0 to 23.
     44  * tm_mday  - Day of the month. This ranges from 1 to 31.
     45  * tm_mon   - Months since January. This ranges from 0 to 11.
     46  * tm_year  - Years since 1900.
     47  * tm_wday  - Days since Sunday. This ranges from 0 to 6.
     48  * tm_yday  - Days since January 1. This ranges from 0 to 365.
     49  * tm_isdst - Flag to indicate whether daylight saving time is in effect. The
     50  *            value is positive if it is in effect, zero if it is not, and
     51  *            negative if the information is not available.
     52  */
     53 typedef struct {
     54     int tm_sec;     ///< seconds
     55     int tm_min;     ///< minutes
     56     int tm_hour;    ///< hours
     57     int tm_mday;    ///< day of the month
     58     int tm_mon;     ///< month
     59     int tm_year;    ///< year
     60     int tm_wday;    ///< day of the week
     61     int tm_yday;    ///< day of the year
     62     int tm_isdst;   ///< daylight savings time
     63 } rs_tm;
     64 
     65 /**
     66  * Returns the number of seconds since the Epoch (00:00:00 UTC, January 1,
     67  * 1970). If @p timer is non-NULL, the result is also stored in the memory
     68  * pointed to by this variable. If an error occurs, a value of -1 is returned.
     69  *
     70  * @param timer Location to also store the returned calendar time.
     71  *
     72  * @return Seconds since the Epoch.
     73  */
     74 extern rs_time_t __attribute__((overloadable))
     75     rsTime(rs_time_t *timer);
     76 
     77 /**
     78  * Converts the time specified by @p timer into broken-down time and stores it
     79  * in @p local. This function also returns a pointer to @p local. If @p local
     80  * is NULL, this function does nothing and returns NULL.
     81  *
     82  * @param local Broken-down time.
     83  * @param timer Input time as calendar time.
     84  *
     85  * @return Pointer to broken-down time (same as input @p local).
     86  */
     87 extern rs_tm * __attribute__((overloadable))
     88     rsLocaltime(rs_tm *local, const rs_time_t *timer);
     89 
     90 /**
     91  * Returns the current system clock (uptime) in milliseconds.
     92  *
     93  * @return Uptime in milliseconds.
     94  */
     95 extern int64_t __attribute__((overloadable))
     96     rsUptimeMillis(void);
     97 
     98 /**
     99  * Returns the current system clock (uptime) in nanoseconds.
    100  *
    101  * @return Uptime in nanoseconds.
    102  */
    103 extern int64_t __attribute__((overloadable))
    104     rsUptimeNanos(void);
    105 
    106 /**
    107  * Returns the time in seconds since this function was last called in this
    108  * script.
    109  *
    110  * @return Time in seconds.
    111  */
    112 extern float __attribute__((overloadable))
    113     rsGetDt(void);
    114 
    115 #endif
    116