diff options
author | shura <d.cirasino1@studenti.uniba.it> | 2019-02-24 18:09:47 +0100 |
---|---|---|
committer | Filipe Coelho <falktx@falktx.com> | 2019-02-24 18:09:47 +0100 |
commit | bb3f5cb2963dc74ba045a1553e05f755af8623cc (patch) | |
tree | d768933a6e8dee6789f038bec3e6557c37986a3a /macosx | |
parent | 2bcacf66b4fa0140c16e5ec592e21884f9d4d8a3 (diff) | |
download | jack2-bb3f5cb2963dc74ba045a1553e05f755af8623cc.tar.gz |
Solving problems while compiling jack2 on macOS X with dbus support (#434)
* Solving problems while compiling jack2 on macOS X with dbus support
* Using the right function name in uptime error
Diffstat (limited to 'macosx')
-rw-r--r-- | macosx/uptime.c | 17 | ||||
-rw-r--r-- | macosx/uptime.h | 27 |
2 files changed, 44 insertions, 0 deletions
diff --git a/macosx/uptime.c b/macosx/uptime.c new file mode 100644 index 00000000..7146fb52 --- /dev/null +++ b/macosx/uptime.c @@ -0,0 +1,17 @@ +#include <time.h> +#include <errno.h> +#include <sys/sysctl.h> + +long uptime(void) +{ + struct timeval boottime; + size_t len = sizeof(boottime); + int mib[2] = { CTL_KERN, KERN_BOOTTIME }; + if (sysctl(mib, 2, &boottime, &len, NULL, 0) < 0) + { + return -1L; + } + time_t bsec = boottime.tv_sec, csec = time(NULL); + + return (long) difftime(csec, bsec); +} diff --git a/macosx/uptime.h b/macosx/uptime.h new file mode 100644 index 00000000..8fc5df11 --- /dev/null +++ b/macosx/uptime.h @@ -0,0 +1,27 @@ +/* +Copyright (C) 2004-2005 Grame + +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 +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef __uptime_APPLE__ +#define __uptime_APPLE__ + +#define UPTIME_FUNCTION_NAME "sysctl" + +long uptime(void); + +#endif |