From 9b8aa5f57e6a21b7916d0e528411f3b9feb5f5e4 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Thu, 29 Apr 2010 14:15:32 -0700 Subject: [PATCH] Extend libspl as required for linux FMA integration. These changes lay some of the ground work for supporting something similar to FMA event under Solaris. In particular these changes add or modify the following areas. First off an implementation of the gethrestime() function is added to libspl. Secondly, the missing type processorid_t has been added. And finally the lib/libspl/include/sys/fm/{protocol.h|util.h} stub headers have been removed in favor of updating the full versions in module/zfs/include/sys/fm/{protocol.h|util.h} to work cleanly in both user and kernel space. --- lib/libspl/Makefile.am | 1 + .../{include/sys/fm/util.h => gethrestime.c} | 21 ++++++++----- lib/libspl/include/Makefile.am | 1 - lib/libspl/include/sys/fm/protocol.h | 30 ------------------- lib/libspl/include/sys/processor.h | 2 ++ lib/libspl/include/sys/time.h | 7 ++++- 6 files changed, 22 insertions(+), 40 deletions(-) rename lib/libspl/{include/sys/fm/util.h => gethrestime.c} (69%) delete mode 100644 lib/libspl/include/sys/fm/protocol.h diff --git a/lib/libspl/Makefile.am b/lib/libspl/Makefile.am index ed8550c222..c4bdcef09b 100644 --- a/lib/libspl/Makefile.am +++ b/lib/libspl/Makefile.am @@ -14,6 +14,7 @@ lib_LTLIBRARIES = libspl.la libspl_la_SOURCES = \ ${top_srcdir}/lib/libspl/getexecname.c \ ${top_srcdir}/lib/libspl/gethrtime.c \ + ${top_srcdir}/lib/libspl/gethrestime.c \ ${top_srcdir}/lib/libspl/getmntany.c \ ${top_srcdir}/lib/libspl/list.c \ ${top_srcdir}/lib/libspl/mkdirp.c \ diff --git a/lib/libspl/include/sys/fm/util.h b/lib/libspl/gethrestime.c similarity index 69% rename from lib/libspl/include/sys/fm/util.h rename to lib/libspl/gethrestime.c index c7ba55ecd4..be163f86ce 100644 --- a/lib/libspl/include/sys/fm/util.h +++ b/lib/libspl/gethrestime.c @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. @@ -19,15 +18,21 @@ * * CDDL HEADER END */ + /* * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ -#ifndef _LIBSPL_SYS_FM_UTIL_H -#define _LIBSPL_SYS_FM_UTIL_H +#include +#include -static inline void fm_init(void) { } -static inline void fm_fini(void) { } +void +gethrestime(timestruc_t *ts) +{ + struct timeval tv; -#endif + gettimeofday(&tv, NULL); + ts->tv_sec = tv.tv_sec; + ts->tv_nsec = tv.tv_usec * NSEC_PER_USEC; +} diff --git a/lib/libspl/include/Makefile.am b/lib/libspl/include/Makefile.am index b47fad2395..ced8e9c09a 100644 --- a/lib/libspl/include/Makefile.am +++ b/lib/libspl/include/Makefile.am @@ -2,7 +2,6 @@ nobase_pkginclude_HEADERS = *.h nobase_pkginclude_HEADERS += ia32/sys/*.h nobase_pkginclude_HEADERS += rpc/*.h nobase_pkginclude_HEADERS += sys/*.h -nobase_pkginclude_HEADERS += sys/fm/*.h nobase_pkginclude_HEADERS += sys/dktp/*.h nobase_pkginclude_HEADERS += sys/sysevent/*.h nobase_pkginclude_HEADERS += tsol/*.h diff --git a/lib/libspl/include/sys/fm/protocol.h b/lib/libspl/include/sys/fm/protocol.h deleted file mode 100644 index 4e146d8b9a..0000000000 --- a/lib/libspl/include/sys/fm/protocol.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _LIBSPL_SYS_FM_PROTOCOL_H -#define _LIBSPL_SYS_FM_PROTOCOL_H - -#endif diff --git a/lib/libspl/include/sys/processor.h b/lib/libspl/include/sys/processor.h index ce80c88dfb..0af9dc06b7 100644 --- a/lib/libspl/include/sys/processor.h +++ b/lib/libspl/include/sys/processor.h @@ -29,4 +29,6 @@ #define getcpuid() (-1) +typedef int processorid_t; + #endif diff --git a/lib/libspl/include/sys/time.h b/lib/libspl/include/sys/time.h index bb5af8c8b4..dc6e4f574f 100644 --- a/lib/libspl/include/sys/time.h +++ b/lib/libspl/include/sys/time.h @@ -31,9 +31,14 @@ #include #ifndef NANOSEC -#define NANOSEC 1000000000 +#define NANOSEC 1000000000 +#endif + +#ifndef NSEC_PER_USEC +#define NSEC_PER_USEC 1000L #endif extern hrtime_t gethrtime(void); +extern void gethrestime(timestruc_t *); #endif