dd: speed measurement. optional.
[oweals/busybox.git] / util-linux / rtcwake.c
index 9a73ba29c3b821232887bab668bf16dd66749d5e..4d2be00f5636e0042e8f5f2794e2e99ac346ff27 100644 (file)
@@ -30,9 +30,7 @@
 #define SYS_POWER_PATH "/sys/power/state"
 #define DEFAULT_MODE   "standby"
 
-static time_t rtc_time;
-
-static bool may_wakeup(const char *rtcname)
+static NOINLINE bool may_wakeup(const char *rtcname)
 {
        ssize_t ret;
        char buf[128];
@@ -50,7 +48,7 @@ static bool may_wakeup(const char *rtcname)
        return strncmp(buf, "enabled\n", 8) == 0;
 }
 
-static void setup_alarm(int fd, time_t *wakeup)
+static NOINLINE void setup_alarm(int fd, time_t *wakeup, time_t rtc_time)
 {
        struct tm *tm;
        struct linux_rtc_wkalrm wake;
@@ -102,6 +100,8 @@ static void setup_alarm(int fd, time_t *wakeup)
 int rtcwake_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
 int rtcwake_main(int argc UNUSED_PARAM, char **argv)
 {
+       time_t rtc_time;
+
        unsigned opt;
        const char *rtcname = NULL;
        const char *suspend;
@@ -114,7 +114,7 @@ int rtcwake_main(int argc UNUSED_PARAM, char **argv)
        int utc = -1;
        int fd;
 
-#if ENABLE_GETOPT_LONG
+#if ENABLE_LONG_OPTS
        static const char rtcwake_longopts[] ALIGN1 =
                "auto\0"    No_argument "a"
                "local\0"   No_argument "l"
@@ -170,7 +170,7 @@ int rtcwake_main(int argc UNUSED_PARAM, char **argv)
                alarm_time += sys_time - rtc_time;
        } else
                alarm_time = rtc_time + seconds + 1;
-       setup_alarm(fd, &alarm_time);
+       setup_alarm(fd, &alarm_time, rtc_time);
 
        sync();
        printf("wakeup from \"%s\" at %s", suspend, ctime(&alarm_time));