* configure.ac: Added check for sys/loadavg.h (for OpenSolaris).
[cacao.git] / src / vm / os.hpp
index 10da1fe9023e7e5bf3fa0a3ce4203121be69a9b7..c812c33f9d684eb08265f8ed0d32a328b7e77d5a 100644 (file)
 # include <unistd.h>
 #endif
 
+#if defined(HAVE_SYS_LOADAVG_H)
+# include <sys/loadavg.h>
+#endif
+
 #if defined(HAVE_SYS_MMAN_H)
 # include <sys/mman.h>
 #endif
@@ -135,6 +139,7 @@ public:
        static inline void    free(void* ptr);
        static inline char*   getenv(const char* name);
        static inline int     gethostname(char* name, size_t len);
+       static inline int     getloadavg(double loadavg[], int nelem);
        static inline int     getpagesize(void);
        static inline int     getsockname(int s, struct sockaddr* name, socklen_t* namelen);
        static inline int     getsockopt(int s, int level, int optname, void* optval, socklen_t* optlen);
@@ -391,6 +396,15 @@ inline int os::gethostname(char* name, size_t len)
 #endif
 }
 
+inline int os::getloadavg(double loadavg[], int nelem)
+{
+#if defined(HAVE_GETLOADAVG)
+       return ::getloadavg(loadavg, nelem);
+#else
+# error getloadavg not available
+#endif
+}
+
 inline int os::getpagesize(void)
 {
 #if defined(HAVE_GETPAGESIZE)