]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
BeOS portability.
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 22 Aug 2006 17:42:21 +0000 (17:42 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 22 Aug 2006 17:42:21 +0000 (17:42 +0000)
* src/uptime.c: Include OS.h if it exists.
(print_uptime): On BeOS, use the get_system_info function (actually a
macro). Loop through utmp entries only if utmp.h or utmpx.h exists.
(uptime): Call read_utmp only if utmp.h or utmpx.h exists.
* m4/boottime.m4 (GNULIB_BOOT_TIME): Test also for utmp.h, utmpx.h,
OS.h. Don't require to have utmp.h or utmpx.h. Enable boottime
support if <OS.h> is found.

ChangeLog
m4/ChangeLog
m4/boottime.m4
src/uptime.c

index 01b70d6e1b688ffec13f7805d4c6fb0d08e50861..faaf8378be59ea3dea8d32e66d2bcb7c16c8fe5e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2006-08-22  Bruno Haible  <bruno@clisp.org>
+
+       BeOS portability.
+       * src/uptime.c: Include OS.h if it exists.
+       (print_uptime): On BeOS, use the get_system_info function (actually a
+       macro). Loop through utmp entries only if utmp.h or utmpx.h exists.
+       (uptime): Call read_utmp only if utmp.h or utmpx.h exists.
+
 2006-08-22  Jim Meyering  <jim@meyering.net>
 
        * .cvsignore: Add ABOUT-NLS.
index 1f73b7280dd62d0a6fbdfa008c99806bb974865e..a99c7129d6e7e1843480cc19f61cc1bc917275a6 100644 (file)
@@ -1,3 +1,10 @@
+2006-08-22  Bruno Haible  <bruno@clisp.org>
+
+       BeOS portability.
+       * boottime.m4 (GNULIB_BOOT_TIME): Test also for utmp.h, utmpx.h,
+       OS.h. Don't require to have utmp.h or utmpx.h. Enable boottime
+       support if <OS.h> is found.
+
 2006-08-22  Jim Meyering  <jim@meyering.net>
 
        * .cvsignore: Add files that are now generated by ../bootstrap.
index e7b742d7f6c9f6b878ee46f3d44fc29d66a88412..ad350f1d8d90322c096be8b38691a78f336e8094 100644 (file)
@@ -1,7 +1,7 @@
-# boottime.m4 serial 2
+# boottime.m4 serial 3
 # Determine whether this system has infrastructure for obtaining the boot time.
 
-# Copyright (C) 1996, 2000, 2002, 2003, 2004 Free Software Foundation, Inc.
+# Copyright (C) 1996, 2000, 2002, 2003, 2004, 2006 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -28,6 +28,7 @@ AC_DEFUN([GNULIB_BOOT_TIME],
      [#if HAVE_SYS_PARAM_H
        #include <sys/param.h>
       #endif]])
+  AC_CHECK_HEADERS_ONCE(utmp.h utmpx.h OS.h)
   AC_CACHE_CHECK(
     [whether we can get the system boot time],
     [gnulib_cv_have_boot_time],
@@ -41,14 +42,17 @@ AC_DEFUN([GNULIB_BOOT_TIME],
 # endif
 # include <sys/sysctl.h>
 #endif
-#ifdef HAVE_UTMPX_H
+#if HAVE_UTMPX_H
 # include <utmpx.h>
-#else
+#elif HAVE_UTMP_H
 # include <utmp.h>
 #endif
+#if HAVE_OS_H
+# include <OS.h>
+#endif
 ],
 [[
-#if defined BOOT_TIME || (defined CTL_KERN && defined KERN_BOOTTIME)
+#if defined BOOT_TIME || (defined CTL_KERN && defined KERN_BOOTTIME) || HAVE_OS_H
 /* your system *does* have the infrastructure to determine boot time */
 #else
 please_tell_us_how_to_determine_boot_time_on_your_system
index bd2b0ec95b3b51101e3b5554464f133e45a5ed08..6b2a7240a4efb079356e3f0cf727298d9e26a01d 100644 (file)
@@ -1,5 +1,5 @@
 /* GNU's uptime.
-   Copyright (C) 1992-2002, 2004, 2005 Free Software Foundation, Inc.
+   Copyright (C) 1992-2002, 2004, 2005, 2006 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
 # include <sys/sysctl.h>
 #endif
 
+#if HAVE_OS_H
+# include <OS.h>
+#endif
+
 #include "c-strtod.h"
 #include "error.h"
 #include "long-options.h"
@@ -90,6 +94,16 @@ print_uptime (size_t n, const STRUCT_UTMP *this)
   }
 #endif
 
+#if HAVE_OS_H /* BeOS */
+  {
+    system_info si;
+
+    get_system_info (&si);
+    boot_time = si.boot_time / 1000000;
+  }
+#endif
+
+#if HAVE_UTMPX_H || HAVE_UTMP_H
   /* Loop through all the utmp entries we just read and count up the valid
      ones, also in the process possibly gleaning boottime. */
   while (n--)
@@ -99,6 +113,7 @@ print_uptime (size_t n, const STRUCT_UTMP *this)
        boot_time = UT_TIME_MEMBER (this);
       ++this;
     }
+#endif
   time_now = time (NULL);
 #if defined HAVE_PROC_UPTIME
   if (uptime == 0)
@@ -163,8 +178,10 @@ uptime (const char *filename, int options)
   size_t n_users;
   STRUCT_UTMP *utmp_buf;
 
+#if HAVE_UTMPX_H || HAVE_UTMP_H
   if (read_utmp (filename, &n_users, &utmp_buf, options) != 0)
     error (EXIT_FAILURE, errno, "%s", filename);
+#endif
 
   print_uptime (n_users, utmp_buf);
 }