本文整理汇总了C++中ANDROID_ALARM_GET_TIME函数的典型用法代码示例。如果您正苦于以下问题:C++ ANDROID_ALARM_GET_TIME函数的具体用法?C++ ANDROID_ALARM_GET_TIME怎么用?C++ ANDROID_ALARM_GET_TIME使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ANDROID_ALARM_GET_TIME函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: alarm_do_ioctl
static long alarm_do_ioctl(struct file *file, unsigned int cmd,
struct timespec *ts)
{
int rv = 0;
unsigned long flags;
enum android_alarm_type alarm_type = ANDROID_ALARM_IOCTL_TO_TYPE(cmd);
if (alarm_type >= ANDROID_ALARM_TYPE_COUNT)
return -EINVAL;
if (ANDROID_ALARM_BASE_CMD(cmd) != ANDROID_ALARM_GET_TIME(0) && ANDROID_ALARM_BASE_CMD(cmd) != ANDROID_ALARM_WAIT_CHANGE) {
if ((file->f_flags & O_ACCMODE) == O_RDONLY)
return -EPERM;
if (file->private_data == NULL &&
cmd != ANDROID_ALARM_SET_RTC) {
spin_lock_irqsave(&alarm_slock, flags);
if (alarm_opened) {
spin_unlock_irqrestore(&alarm_slock, flags);
return -EBUSY;
}
alarm_opened = 1;
file->private_data = (void *)1;
spin_unlock_irqrestore(&alarm_slock, flags);
}
}
switch (ANDROID_ALARM_BASE_CMD(cmd)) {
case ANDROID_ALARM_CLEAR(0):
alarm_clear(alarm_type);
break;
case ANDROID_ALARM_SET(0):
alarm_set(alarm_type, ts);
break;
case ANDROID_ALARM_SET_AND_WAIT(0):
alarm_set(alarm_type, ts);
/* fall though */
case ANDROID_ALARM_WAIT:
rv = alarm_wait();
break;
case ANDROID_ALARM_WAIT_CHANGE:
{
rv = wait_event_interruptible(alarm_wait_change_queue, delta);
if (rv == -ERESTARTSYS) {
rv = -EINTR;
}
break;
}
case ANDROID_ALARM_SET_RTC:
rv = alarm_set_rtc(ts);
break;
case ANDROID_ALARM_GET_TIME(0):
rv = alarm_get_time(alarm_type, ts);
break;
default:
rv = -EINVAL;
}
err1:
return rv;
}
示例2: alarm_do_ioctl
static long alarm_do_ioctl(struct file *file, unsigned int cmd,
struct timespec *ts)
{
int rv = 0;
unsigned long flags;
enum android_alarm_type alarm_type = ANDROID_ALARM_IOCTL_TO_TYPE(cmd);
if (alarm_type >= ANDROID_ALARM_TYPE_COUNT)
return -EINVAL;
if (ANDROID_ALARM_BASE_CMD(cmd) != ANDROID_ALARM_GET_TIME(0)) {
if ((file->f_flags & O_ACCMODE) == O_RDONLY)
return -EPERM;
if (file->private_data == NULL &&
cmd != ANDROID_ALARM_SET_RTC) {
spin_lock_irqsave(&alarm_slock, flags);
if (alarm_opened) {
spin_unlock_irqrestore(&alarm_slock, flags);
return -EBUSY;
}
alarm_opened = 1;
file->private_data = (void *)1;
spin_unlock_irqrestore(&alarm_slock, flags);
}
}
switch (ANDROID_ALARM_BASE_CMD(cmd)) {
case ANDROID_ALARM_CLEAR(0):
alarm_clear(alarm_type);
break;
case ANDROID_ALARM_SET(0):
alarm_set(alarm_type, ts);
break;
case ANDROID_ALARM_SET_AND_WAIT(0):
alarm_set(alarm_type, ts);
/* fall though */
case ANDROID_ALARM_WAIT:
rv = alarm_wait();
break;
case ANDROID_ALARM_SET_RTC:
rv = alarm_set_rtc(ts);
break;
#ifdef CONFIG_RTC_BOOT_ALARM
case ANDROID_ALARM_SET_BOOT_ALARM:
rv = alarm_set_boot_alarm(ts);
break;
#endif
case ANDROID_ALARM_GET_TIME(0):
rv = alarm_get_time(alarm_type, ts);
break;
default:
rv = -EINVAL;
}
return rv;
}
示例3: GKI_now_us
UINT64 GKI_now_us()
{
struct timespec ts_now;
#ifdef HAVE_ANDROID_OS
static int s_fd = -1;
int result;
if (s_fd == -1) {
int fd = open("/dev/alarm", O_RDONLY);
if (android_atomic_cmpxchg(-1, fd, &s_fd)) {
close(fd);
}
}
result = ioctl(s_fd,
ANDROID_ALARM_GET_TIME(ANDROID_ALARM_ELAPSED_REALTIME), &ts_now);
if (result != 0) {
#endif
clock_gettime(CLOCK_BOOTTIME, &ts_now);
#ifdef HAVE_ANDROID_OS
}
#endif
return ((UINT64)ts_now.tv_sec * USEC_PER_SEC) + ((UINT64)ts_now.tv_nsec / NSEC_PER_USEC);
}
示例4: elapsedRealtime
/*
* native public static long elapsedRealtime();
*/
int64_t elapsedRealtime()
{
#ifdef HAVE_ANDROID_OS
static int s_fd = -1;
if (s_fd == -1) {
int fd = open("/dev/alarm", O_RDONLY);
if (android_atomic_cmpxchg(-1, fd, &s_fd)) {
close(fd);
}
}
struct timespec ts;
int result = ioctl(s_fd,
ANDROID_ALARM_GET_TIME(ANDROID_ALARM_ELAPSED_REALTIME), &ts);
if (result == 0) {
int64_t when = seconds_to_nanoseconds(ts.tv_sec) + ts.tv_nsec;
return (int64_t) nanoseconds_to_milliseconds(when);
} else {
// XXX: there was an error, probably because the driver didn't
// exist ... this should return
// a real error, like an exception!
int64_t when = systemTime(SYSTEM_TIME_MONOTONIC);
return (int64_t) nanoseconds_to_milliseconds(when);
}
#else
int64_t when = systemTime(SYSTEM_TIME_MONOTONIC);
return (int64_t) nanoseconds_to_milliseconds(when);
#endif
}
示例5: alarm_compat_ioctl
static long alarm_compat_ioctl(struct file *file, unsigned int cmd,
unsigned long arg)
{
struct timespec ts;
int rv;
switch (ANDROID_ALARM_BASE_CMD(cmd)) {
case ANDROID_ALARM_SET_AND_WAIT_COMPAT(0):
case ANDROID_ALARM_SET_COMPAT(0):
case ANDROID_ALARM_SET_RTC_COMPAT:
if (compat_get_timespec(&ts, (void __user *)arg))
return -EFAULT;
/* fall through */
case ANDROID_ALARM_GET_TIME_COMPAT(0):
cmd = ANDROID_ALARM_COMPAT_TO_NORM(cmd);
break;
}
rv = alarm_do_ioctl(file, cmd, &ts);
if (rv)
return rv;
switch (ANDROID_ALARM_BASE_CMD(cmd)) {
case ANDROID_ALARM_GET_TIME(0): /* NOTE: we modified cmd above */
if (compat_put_timespec(&ts, (void __user *)arg))
return -EFAULT;
break;
}
return 0;
}
示例6: alarm_ioctl
static long alarm_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
struct timespec ts;
int rv;
switch (ANDROID_ALARM_BASE_CMD(cmd)) {
case ANDROID_ALARM_SET_AND_WAIT(0):
case ANDROID_ALARM_SET(0):
case ANDROID_ALARM_SET_RTC:
if (copy_from_user(&ts, (void __user *)arg, sizeof(ts)))
return -EFAULT;
break;
}
rv = alarm_do_ioctl(file, cmd, &ts);
if (rv)
return rv;
switch (ANDROID_ALARM_BASE_CMD(cmd)) {
case ANDROID_ALARM_GET_TIME(0):
if (copy_to_user((void __user *)arg, &ts, sizeof(ts)))
return -EFAULT;
break;
}
return 0;
}
示例7: elapsedRealtimeNano
/*
* native public static long elapsedRealtimeNano();
*/
int64_t elapsedRealtimeNano()
{
#ifdef HAVE_ANDROID_OS
struct timespec ts;
int result;
int64_t timestamp;
#if DEBUG_TIMESTAMP
static volatile int64_t prevTimestamp;
static volatile int prevMethod;
#endif
static int s_fd = -1;
if (s_fd == -1) {
int fd = open("/dev/alarm", O_RDONLY);
if (android_atomic_cmpxchg(-1, fd, &s_fd)) {
close(fd);
}
}
result = ioctl(s_fd,
ANDROID_ALARM_GET_TIME(ANDROID_ALARM_ELAPSED_REALTIME), &ts);
if (result == 0) {
timestamp = seconds_to_nanoseconds(ts.tv_sec) + ts.tv_nsec;
checkTimeStamps(timestamp, &prevTimestamp, &prevMethod, METHOD_IOCTL);
return timestamp;
}
// /dev/alarm doesn't exist, fallback to CLOCK_BOOTTIME
result = clock_gettime(CLOCK_BOOTTIME, &ts);
if (result == 0) {
timestamp = seconds_to_nanoseconds(ts.tv_sec) + ts.tv_nsec;
checkTimeStamps(timestamp, &prevTimestamp, &prevMethod,
METHOD_CLOCK_GETTIME);
return timestamp;
}
// XXX: there was an error, probably because the driver didn't
// exist ... this should return
// a real error, like an exception!
timestamp = systemTime(SYSTEM_TIME_MONOTONIC);
checkTimeStamps(timestamp, &prevTimestamp, &prevMethod,
METHOD_SYSTEMTIME);
return timestamp;
#else
return systemTime(SYSTEM_TIME_MONOTONIC);
#endif
}
示例8: elapsedRealtime
int64_t elapsedRealtime()
{
struct timespec ts;
int fd, result;
fd = open("/dev/alarm", O_RDONLY);
if (fd < 0)
return fd;
result = ioctl(fd, ANDROID_ALARM_GET_TIME(ANDROID_ALARM_ELAPSED_REALTIME), &ts);
close(fd);
if (result == 0)
return ts.tv_sec;
return -1;
}
示例9: alarm_ioctl
static long alarm_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
struct timespec ts;
int rv;
#if defined(CONFIG_RTC_ALARM_BOOT)
char bootalarm_data[14];
#endif
switch (ANDROID_ALARM_BASE_CMD(cmd)) {
case ANDROID_ALARM_SET_AND_WAIT(0):
case ANDROID_ALARM_SET(0):
case ANDROID_ALARM_SET_RTC:
if (copy_from_user(&ts, (void __user *)arg, sizeof(ts)))
return -EFAULT;
break;
#if defined(CONFIG_RTC_ALARM_BOOT)
case ANDROID_ALARM_SET_ALARM_BOOT:
if (copy_from_user(bootalarm_data, (void __user *)arg, 14)) {
return -EFAULT;
}
rv = alarm_set_alarm_boot(bootalarm_data);
alarm_opened = 1;
return rv;
break;
#endif
}
rv = alarm_do_ioctl(file, cmd, &ts);
if (rv)
return rv;
switch (ANDROID_ALARM_BASE_CMD(cmd)) {
case ANDROID_ALARM_GET_TIME(0):
if (copy_to_user((void __user *)arg, &ts, sizeof(ts)))
return -EFAULT;
break;
}
return 0;
}
示例10: alarm_compat_ioctl
static long alarm_compat_ioctl(struct file *file, unsigned int cmd,
unsigned long arg)
{
struct timespec ts;
struct rtc_wkalrm pwron_alm;
int rv;
switch (ANDROID_ALARM_BASE_CMD(cmd)) {
case ANDROID_ALARM_SET_AND_WAIT_COMPAT(0):
case ANDROID_ALARM_SET_COMPAT(0):
case ANDROID_ALARM_SET_RTC_COMPAT:
case ANDROID_ALARM_SET_IPO_COMPAT(0):
if (compat_get_timespec(&ts, (void __user *)arg))
return -EFAULT;
/* fall through */
case ANDROID_ALARM_GET_TIME_COMPAT(0):
cmd = ANDROID_ALARM_COMPAT_TO_NORM(cmd);
break;
}
rv = alarm_do_ioctl(file, cmd, &ts, &pwron_alm);
if (rv)
return rv;
switch (ANDROID_ALARM_BASE_CMD(cmd)) {
case ANDROID_ALARM_GET_TIME(0): /* NOTE: we modified cmd above */
if (compat_put_timespec(&ts, (void __user *)arg))
return -EFAULT;
break;
case ANDROID_ALARM_GET_POWER_ON:
case ANDROID_ALARM_GET_POWER_ON_IPO:
if (copy_to_user((void __user *)arg, &pwron_alm,
sizeof(struct rtc_wkalrm))) {
rv = -EFAULT;
return rv;
}
break;
}
return 0;
}
示例11: alarm_ioctl
static long alarm_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
struct timespec ts;
int rv;
switch (ANDROID_ALARM_BASE_CMD(cmd)) {
case ANDROID_ALARM_SET_AND_WAIT(0):
case ANDROID_ALARM_SET(0):
case ANDROID_ALARM_SET_RTC:
if (copy_from_user(&ts, (void __user *)arg, sizeof(ts)))
return -EFAULT;
break;
}
rv = alarm_do_ioctl(file, cmd, &ts);
if (rv)
return rv;
switch (ANDROID_ALARM_BASE_CMD(cmd)) {
case ANDROID_ALARM_GET_TIME(0):
if (copy_to_user((void __user *)arg, &ts, sizeof(ts)))
return -EFAULT;
break;
case ANDROID_ALARM_WAIT_CHANGE:
{
unsigned long flags;
spin_lock_irqsave(&alarm_slock, flags);
if (copy_to_user((void __user *)arg, &delta, 4)) {
rv = -EFAULT;
delta = 0;
spin_unlock_irqrestore(&alarm_slock, flags);
return rv;
}
delta = 0;
spin_unlock_irqrestore(&alarm_slock, flags);
break;
}
}
return 0;
}
示例12: alarm_ioctl
static long alarm_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
struct timespec ts;
struct rtc_wkalrm pwron_alm;
int rv;
switch (ANDROID_ALARM_BASE_CMD(cmd)) {
case ANDROID_ALARM_SET_AND_WAIT(0):
case ANDROID_ALARM_SET(0):
case ANDROID_ALARM_SET_RTC:
case ANDROID_ALARM_SET_IPO(0):
if (copy_from_user(&ts, (void __user *)arg, sizeof(ts)))
return -EFAULT;
break;
}
rv = alarm_do_ioctl(file, cmd, &ts, &pwron_alm);
if (rv)
return rv;
switch (ANDROID_ALARM_BASE_CMD(cmd)) {
case ANDROID_ALARM_GET_TIME(0):
if (copy_to_user((void __user *)arg, &ts, sizeof(ts)))
return -EFAULT;
break;
case ANDROID_ALARM_GET_POWER_ON:
case ANDROID_ALARM_GET_POWER_ON_IPO:
if (copy_to_user((void __user *)arg,
&pwron_alm, sizeof(struct rtc_wkalrm))) {
rv = -EFAULT;
return rv;
}
break;
default:
break;
}
return 0;
}
示例13: alarm_ioctl
static long alarm_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
struct timespec ts;
int rv;
#ifdef CONFIG_RTC_AUTO_PWRON
char bootalarm_data[14];
#endif
switch (ANDROID_ALARM_BASE_CMD(cmd)) {
case ANDROID_ALARM_SET_AND_WAIT(0):
case ANDROID_ALARM_SET(0):
case ANDROID_ALARM_SET_RTC:
case ANDROID_ALARM_CLEAR(0):
if (copy_from_user(&ts, (void __user *)arg, sizeof(ts)))
return -EFAULT;
break;
#ifdef CONFIG_RTC_AUTO_PWRON
case ANDROID_ALARM_SET_ALARM:
pr_info("[SAPA] %s\n", __func__);
if (copy_from_user(bootalarm_data, (void __user *)arg, 14))
rv = -EFAULT;
rv = alarm_set_alarm(bootalarm_data);
break;
#endif
}
rv = alarm_do_ioctl(file, cmd, &ts);
if (rv)
return rv;
switch (ANDROID_ALARM_BASE_CMD(cmd)) {
case ANDROID_ALARM_GET_TIME(0):
if (copy_to_user((void __user *)arg, &ts, sizeof(ts)))
return -EFAULT;
break;
}
return 0;
}
示例14: is_set_cmd
static int is_set_cmd(unsigned int cmd)
{
if (ANDROID_ALARM_BASE_CMD(cmd) != ANDROID_ALARM_GET_TIME(0))
return 1;
return 0;
}
示例15: alarm_main
//.........这里部分代码省略.........
#if 0
t = timegm(&tm);
if(useutc)
gmtime_r(&t, &tm);
else
localtime_r(&t, &tm);
#endif
#if 0
asctime_r(&tm, strbuf);
printf("%s", strbuf);
#endif
}
else if(optind + 1 == argc) {
#if 0
res = ioctl(fd, RTC_RD_TIME, &tm);
if(res < 0) {
fprintf(stderr, "Unable to set alarm: %s\n", strerror(errno));
return 1;
}
asctime_r(&tm, strbuf);
printf("Now: %s", strbuf);
time(&tv.tv_sec);
#endif
#if 0
time(&ts.tv_sec);
ts.tv_nsec = 0;
//strptime(argv[optind], NULL, &tm);
//tv.tv_sec = mktime(&tm);
//tv.tv_usec = 0;
#endif
for(alarmtype = alarmtype_low; alarmtype <= alarmtype_high; alarmtype++) {
waitalarmmask |= 1U << alarmtype;
res = ioctl(afd, ANDROID_ALARM_GET_TIME(alarmtype), &ts);
if(res < 0) {
fprintf(stderr, "Unable to get current time: %s\n", strerror(errno));
return 1;
}
ts.tv_sec += strtol(argv[optind], NULL, 0);
//strtotimeval(argv[optind], &tv);
gmtime_r(&ts.tv_sec, &tm);
printf("time %s -> %ld.%09ld\n", argv[optind], ts.tv_sec, ts.tv_nsec);
asctime_r(&tm, strbuf);
printf("Requested %s", strbuf);
res = ioctl(afd, ANDROID_ALARM_SET(alarmtype), &ts);
if(res < 0) {
fprintf(stderr, "Unable to set alarm: %s\n", strerror(errno));
return 1;
}
}
#if 0
res = ioctl(fd, RTC_ALM_SET, &tm);
if(res < 0) {
fprintf(stderr, "Unable to set alarm: %s\n", strerror(errno));
return 1;
}
res = ioctl(fd, RTC_AIE_ON);
if(res < 0) {
fprintf(stderr, "Unable to enable alarm: %s\n", strerror(errno));
return 1;
}
#endif
}
else {
fprintf(stderr,"%s [-u] [date]\n", argv[0]);