[SCM] Samba Shared Repository - branch v3-6-test updated

Björn Jacke bjacke at samba.org
Fri Sep 3 09:27:51 MDT 2010


The branch, v3-6-test has been updated
       via  4199f00 s3: use fine grained time in netprot response
       via  35d3907 s3: use monotonic clock for time deltas in smbget
       via  b9b48da tdb/waf: the deps for rt are provided by libreplace
       via  9eea2ce replace/waf: add rt to deps at this place
       via  f590a68 s3: use monotonic time in timeout of sys_select_intr()
       via  3d27fed lib/util: add nsec_time_diff to calulate diffs from timespecs
       via  efb9d7c s3: use monotonic clock for time deltas in namequery functions
       via  b8a8226 s3: use monotonic clock for time deltas in smbtar
       via  7ba741e s3: use monotonic clock for time deltas in smbclient
       via  940b278 s3: add TspecDiff macro
       via  ab88767 lib/util: add function to query the monotonic clock with the required fallback to the realtime clock
       via  84dfa82 libreplace: make a define for a best effort monotonic clock
       via  ed431aa s3: we have clock_gettime everywhere, remove ifdefs
       via  20318f7 s3: use clock_gettime() in timespec_current()
       via  d3ad838 libreplace: add clock_gettime replacement function for systems that don't have it
       via  2479c9b libreplace/waf: look for clock_gettime
       via  abf907f libreplace: move detection of clock_gettime to libreplace
       via  62620a5 libreplace: move gettimeofday TZ arg check here
      from  2ab1635 docs:vfs_gpfs: improve the CAVEAT section on run and build time dependencies

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-6-test


- Log -----------------------------------------------------------------
commit 4199f00ae684020e537c8fb8b6e052a700a0a965
Author: Björn Jacke <bj at sernet.de>
Date:   Wed May 12 10:50:17 2010 +0200

    s3: use fine grained time in netprot response

commit 35d39071f1ba77df9e4ba08c635e414db4835ff4
Author: Björn Jacke <bj at sernet.de>
Date:   Tue Aug 31 13:10:45 2010 +0200

    s3: use monotonic clock for time deltas in smbget

commit b9b48dac02c3b70d51be6138080c8e3aad12999d
Author: Björn Jacke <bj at sernet.de>
Date:   Tue Aug 31 13:06:39 2010 +0200

    tdb/waf: the deps for rt are provided by libreplace

commit 9eea2ce99fe0520fc5ea66869bdb62062680176f
Author: Björn Jacke <bj at sernet.de>
Date:   Tue Aug 31 11:31:19 2010 +0200

    replace/waf: add rt to deps at this place

commit f590a68a590d7c5765ee1dbcc10c7649b0a963c8
Author: Björn Jacke <bj at sernet.de>
Date:   Mon Aug 30 18:02:19 2010 +0200

    s3: use monotonic time in timeout of sys_select_intr()

commit 3d27fedacf6b494ae985083cf17ff3799ee652ba
Author: Björn Jacke <bj at sernet.de>
Date:   Mon Aug 30 17:56:37 2010 +0200

    lib/util: add nsec_time_diff to calulate diffs from timespecs

commit efb9d7c627ba169b1c2da0ee184df4d9fe3c4d8a
Author: Björn Jacke <bj at sernet.de>
Date:   Mon Aug 30 15:46:22 2010 +0200

    s3: use monotonic clock for time deltas in namequery functions

commit b8a82265216db5bb0220ab3a361f8282921dd0cc
Author: Björn Jacke <bj at sernet.de>
Date:   Mon Aug 30 15:44:54 2010 +0200

    s3: use monotonic clock for time deltas in smbtar

commit 7ba741eccfb7f434a66399068a7a61ca9953866c
Author: Björn Jacke <bj at sernet.de>
Date:   Mon Aug 30 12:15:54 2010 +0200

    s3: use monotonic clock for time deltas in smbclient

commit 940b278ba32b5c0698304723a4daabb48fe4d560
Author: Björn Jacke <bj at sernet.de>
Date:   Mon Aug 30 15:30:16 2010 +0200

    s3: add TspecDiff macro

commit ab88767fe8812515c18ca1eca72caba086f8cf42
Author: Björn Jacke <bj at sernet.de>
Date:   Mon Aug 30 12:10:29 2010 +0200

    lib/util: add function to query the monotonic clock with the required fallback to the realtime clock

commit 84dfa8295ce962a255ebfd74f19be48abef7554e
Author: Björn Jacke <bj at sernet.de>
Date:   Thu Aug 26 12:22:02 2010 +0200

    libreplace: make a define for a best effort monotonic clock

commit ed431aa51f4716f37aeb7ae977c871f297d12d13
Author: Björn Jacke <bj at sernet.de>
Date:   Tue Aug 24 11:14:19 2010 +0200

    s3: we have clock_gettime everywhere, remove ifdefs

commit 20318f70228969cdc468c55ab127c463e113bdd4
Author: Björn Jacke <bj at sernet.de>
Date:   Mon Aug 30 16:51:56 2010 +0200

    s3: use clock_gettime() in timespec_current()

commit d3ad838895747e628d4500e37daf7e135046192b
Author: Björn Jacke <bj at sernet.de>
Date:   Thu Aug 19 19:07:04 2010 +0200

    libreplace: add clock_gettime replacement function for systems that don't have it

commit 2479c9b54bfab278159f23db3bcb5f26fb38bed6
Author: Björn Jacke <bj at sernet.de>
Date:   Fri Aug 27 00:13:07 2010 +0200

    libreplace/waf: look for clock_gettime

commit abf907f93bcb831187446399b6aeebc65238bedb
Author: Björn Jacke <bj at sernet.de>
Date:   Thu Aug 19 18:39:45 2010 +0200

    libreplace: move detection of clock_gettime to libreplace

commit 62620a5fdc32a120fa4b895e7286608cb5345870
Author: Björn Jacke <bj at sernet.de>
Date:   Mon Aug 30 14:35:49 2010 +0200

    libreplace: move gettimeofday TZ arg check here

-----------------------------------------------------------------------

Summary of changes:
 lib/replace/README           |    1 +
 lib/replace/libreplace.m4    |   43 ++++++++++++++++++++++++++++++++++++++++++
 lib/replace/replace.c        |   21 ++++++++++++++++++++
 lib/replace/replace.h        |    4 +++
 lib/replace/system/config.m4 |   10 +++++++++
 lib/replace/system/time.h    |   13 ++++++++++++
 lib/replace/wscript          |    3 +-
 lib/tdb/wscript              |    2 +-
 lib/util/time.c              |   19 ++++++++++++++++++
 lib/util/time.h              |   10 +++++++++
 lib/util/time.m4             |    9 --------
 source3/client/client.c      |   28 ++++++++++++--------------
 source3/client/clitar.c      |   14 ++++++------
 source3/configure.in         |   20 +-----------------
 source3/include/smb_macros.h |    9 ++++++++
 source3/include/smbprofile.h |   13 ------------
 source3/lib/select.c         |   21 ++++++++++---------
 source3/lib/time.c           |    5 +---
 source3/libsmb/namequery.c   |   24 +++++++++++-----------
 source3/m4/aclocal.m4        |   31 ------------------------------
 source3/profile/profile.c    |    7 ------
 source3/smbd/negprot.c       |    7 +++--
 source3/utils/smbget.c       |    7 ++++-
 source4/configure.ac         |    1 -
 24 files changed, 188 insertions(+), 134 deletions(-)
 delete mode 100644 lib/util/time.m4


Changeset truncated at 500 lines:

diff --git a/lib/replace/README b/lib/replace/README
index b2d2e4f..bf4e67f 100644
--- a/lib/replace/README
+++ b/lib/replace/README
@@ -33,6 +33,7 @@ opendir
 readdir
 telldir
 seekdir
+clock_gettime
 closedir
 dlopen
 dlclose
diff --git a/lib/replace/libreplace.m4 b/lib/replace/libreplace.m4
index 2303641..0d716e0 100644
--- a/lib/replace/libreplace.m4
+++ b/lib/replace/libreplace.m4
@@ -115,6 +115,12 @@ AC_CHECK_FUNCS(fdatasync,,[
 		[libreplace_cv_HAVE_FDATASYNC_IN_LIBRT=yes
 		AC_DEFINE(HAVE_FDATASYNC, 1, Define to 1 if there is support for fdatasync)])
 ])
+AC_CHECK_FUNCS(clock_gettime,libreplace_cv_have_clock_gettime=yes,[
+	AC_CHECK_LIB(rt, clock_gettime,
+		[libreplace_cv_HAVE_CLOCK_GETTIME_IN_LIBRT=yes
+		libreplace_cv_have_clock_gettime=yes
+		AC_DEFINE(HAVE_CLOCK_GETTIME, 1, Define to 1 if there is support for clock_gettime)])
+])
 AC_CHECK_FUNCS(get_current_dir_name)
 AC_HAVE_DECL(setresuid, [#include <unistd.h>])
 AC_HAVE_DECL(setresgid, [#include <unistd.h>])
@@ -288,6 +294,12 @@ m4_include(timegm.m4)
 m4_include(repdir.m4)
 m4_include(crypt.m4)
 
+if test x$libreplace_cv_have_clock_gettime = xyes ; then
+	SMB_CHECK_CLOCK_ID(CLOCK_MONOTONIC)
+	SMB_CHECK_CLOCK_ID(CLOCK_PROCESS_CPUTIME_ID)
+	SMB_CHECK_CLOCK_ID(CLOCK_REALTIME)
+fi
+
 AC_CHECK_FUNCS([printf memset memcpy],,[AC_MSG_ERROR([Required function not found])])
 
 echo "LIBREPLACE_BROKEN_CHECKS: END"
@@ -316,4 +328,35 @@ m4_include(libreplace_ld.m4)
 m4_include(libreplace_network.m4)
 m4_include(libreplace_macros.m4)
 
+
+dnl SMB_CHECK_CLOCK_ID(clockid)
+dnl Test whether the specified clock_gettime clock ID is available. If it
+dnl is, we define HAVE_clockid
+AC_DEFUN([SMB_CHECK_CLOCK_ID],
+[
+    AC_MSG_CHECKING(for $1)
+    AC_TRY_LINK([
+#if TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# if HAVE_SYS_TIME_H
+#  include <sys/time.h>
+# else
+#  include <time.h>
+# endif
+#endif
+    ],
+    [
+clockid_t clk = $1;
+    ],
+    [
+	AC_MSG_RESULT(yes)
+	AC_DEFINE(HAVE_$1, 1,
+	    [Whether the clock_gettime clock ID $1 is available])
+    ],
+    [
+	AC_MSG_RESULT(no)
+    ])
+])
 m4_ifndef([AC_USE_SYSTEM_EXTENSIONS],[m4_include(autoconf-2.60.m4)])
diff --git a/lib/replace/replace.c b/lib/replace/replace.c
index 12716ea..f3459dd 100644
--- a/lib/replace/replace.c
+++ b/lib/replace/replace.c
@@ -760,3 +760,24 @@ int rep_strerror_r(int errnum, char *buf, size_t buflen)
 	return 0;
 }
 #endif
+
+#ifndef HAVE_CLOCK_GETTIME
+int rep_clock_gettime(clockid_t clk_id, struct timespec *tp)
+{
+	struct timeval tval;
+	switch (clk_id) {
+		case 0: /* CLOCK_REALTIME :*/
+#ifdef HAVE_GETTIMEOFDAY_TZ
+			gettimeofday(&tval,NULL);
+#else
+			gettimeofday(&tval);
+#endif
+			tp->tv_sec = tval.tv_sec;
+			tp->tv_nsec = tval.tv_usec * 1000;
+			break;
+		default:
+			return EINVAL;
+	}
+	return 0;
+}
+#endif
diff --git a/lib/replace/replace.h b/lib/replace/replace.h
index 713634e..7b455a5 100644
--- a/lib/replace/replace.h
+++ b/lib/replace/replace.h
@@ -517,6 +517,10 @@ char *rep_get_current_dir_name(void);
 int rep_strerror_r(int errnum, char *buf, size_t buflen);
 #endif
 
+#if !defined(HAVE_CLOCK_GETTIME)
+#define clock_gettime rep_clock_gettime
+#endif
+
 #ifdef HAVE_LIMITS_H
 #include <limits.h>
 #endif
diff --git a/lib/replace/system/config.m4 b/lib/replace/system/config.m4
index b8568a5..04364bc 100644
--- a/lib/replace/system/config.m4
+++ b/lib/replace/system/config.m4
@@ -11,6 +11,16 @@ AC_CHECK_HEADERS(sys/time.h utime.h)
 AC_HEADER_TIME
 AC_CHECK_FUNCS(utime utimes)
 
+AC_CACHE_CHECK([if gettimeofday takes TZ argument],libreplace_cv_HAVE_GETTIMEOFDAY_TZ,[
+AC_TRY_RUN([
+#include <sys/time.h>
+#include <unistd.h>
+main() { struct timeval tv; exit(gettimeofday(&tv, NULL));}],
+           libreplace_cv_HAVE_GETTIMEOFDAY_TZ=yes,libreplace_cv_HAVE_GETTIMEOFDAY_TZ=no,libreplace_cv_HAVE_GETTIMEOFDAY_TZ=yes)])
+if test x"$libreplace_cv_HAVE_GETTIMEOFDAY_TZ" = x"yes"; then
+    AC_DEFINE(HAVE_GETTIMEOFDAY_TZ,1,[Whether gettimeofday() is available])
+fi
+
 # wait
 AC_HEADER_SYS_WAIT
 
diff --git a/lib/replace/system/time.h b/lib/replace/system/time.h
index 4abf295..3605d26 100644
--- a/lib/replace/system/time.h
+++ b/lib/replace/system/time.h
@@ -66,4 +66,17 @@ int rep_utime(const char *filename, const struct utimbuf *buf);
 int rep_utimes(const char *filename, const struct timeval tv[2]);
 #endif
 
+#ifndef HAVE_CLOCK_GETTIME
+/* CLOCK_REALTIME is required by POSIX */
+#define CLOCK_REALTIME 0
+typedef int clockid_t;
+int rep_clock_gettime(clockid_t clk_id, struct timespec *tp);
+#endif
+/* make sure we have a best effort CUSTOM_CLOCK_MONOTONIC we can rely on */
+#ifndef CLOCK_MONOTONIC
+#define CUSTOM_CLOCK_MONOTONIC CLOCK_REALTIME
+#else
+#define CUSTOM_CLOCK_MONOTONIC CLOCK_MONOTONIC
+#endif
+
 #endif
diff --git a/lib/replace/wscript b/lib/replace/wscript
index 9cdfd7f..d126ae5 100644
--- a/lib/replace/wscript
+++ b/lib/replace/wscript
@@ -173,6 +173,7 @@ def configure(conf):
                            define='DLOPEN_TAKES_UNSIGNED_FLAGS', headers='dlfcn.h dl.h')
 
     conf.CHECK_FUNCS_IN('fdatasync', 'rt', checklibc=True)
+    conf.CHECK_FUNCS_IN('clock_gettime', 'rt', checklibc=True)
 
     # these headers need to be tested as a group on freebsd
     conf.CHECK_HEADERS(headers='sys/socket.h net/if.h', together=True)
@@ -369,7 +370,7 @@ def build(bld):
 					  # libraries are loaded, but this doesn't appear to work 
 					  # at the moment:
 					  # hide_symbols=bld.BUILTIN_LIBRARY('replace'),
-                      deps='crypt dl nsl socket')
+                      deps='crypt dl nsl socket rt')
 
     TEST_SOURCES = '''test/testsuite.c test/main.c test/strptime.c
                       test/os2_delete.c test/getifaddrs.c'''
diff --git a/lib/tdb/wscript b/lib/tdb/wscript
index 2fdd67f..3dfb5ab 100644
--- a/lib/tdb/wscript
+++ b/lib/tdb/wscript
@@ -63,7 +63,7 @@ def build(bld):
     if not bld.CONFIG_SET('USING_SYSTEM_TDB'):
         bld.SAMBA_LIBRARY('tdb',
                           COMMON_SRC,
-                          deps='replace rt',
+                          deps='replace',
                           includes='include',
                           abi_file='ABI/tdb-%s.sigs' % VERSION,
                           abi_match='tdb_*',
diff --git a/lib/util/time.c b/lib/util/time.c
index 571219b..5ecf93c 100644
--- a/lib/util/time.c
+++ b/lib/util/time.c
@@ -55,6 +55,16 @@ _PUBLIC_ void GetTimeOfDay(struct timeval *tval)
 #endif
 }
 
+/**
+a wrapper to preferably get the monotonic time
+**/
+_PUBLIC_ void clock_gettime_mono(struct timespec *tp)
+{
+	if (clock_gettime(CUSTOM_CLOCK_MONOTONIC,tp) != 0) {
+		clock_gettime(CLOCK_REALTIME,tp);
+	}
+}
+
 
 #define TIME_FIXUP_CONSTANT 11644473600LL
 
@@ -399,6 +409,15 @@ _PUBLIC_ int64_t usec_time_diff(const struct timeval *tv1, const struct timeval
 	return (sec_diff * 1000000) + (int64_t)(tv1->tv_usec - tv2->tv_usec);
 }
 
+/**
+  return (tp1 - tp2) in microseconds
+*/
+_PUBLIC_ int64_t nsec_time_diff(const struct timespec *tp1, const struct timespec *tp2)
+{
+	int64_t sec_diff = tp1->tv_sec - tp2->tv_sec;
+	return (sec_diff * 1000000000) + (int64_t)(tp1->tv_nsec - tp2->tv_nsec);
+}
+
 
 /**
   return a zero timeval
diff --git a/lib/util/time.h b/lib/util/time.h
index cf6dc1c..720a262 100644
--- a/lib/util/time.h
+++ b/lib/util/time.h
@@ -51,6 +51,11 @@ a gettimeofday wrapper
 _PUBLIC_ void GetTimeOfDay(struct timeval *tval);
 
 /**
+a wrapper to preferably get the monotonic time
+**/
+_PUBLIC_ void clock_gettime_mono(struct timespec *tp);
+
+/**
 interpret an 8 byte "filetime" structure to a time_t
 It's originally in "100ns units since jan 1st 1601"
 **/
@@ -144,6 +149,11 @@ _PUBLIC_ NTTIME nttime_from_string(const char *s);
 _PUBLIC_ int64_t usec_time_diff(const struct timeval *tv1, const struct timeval *tv2);
 
 /**
+  return (tp1 - tp2) in nanoseconds
+*/
+_PUBLIC_ int64_t nsec_time_diff(const struct timespec *tp1, const struct timespec *tp2);
+
+/**
   return a zero timeval
 */
 _PUBLIC_ struct timeval timeval_zero(void);
diff --git a/lib/util/time.m4 b/lib/util/time.m4
deleted file mode 100644
index 675e201..0000000
--- a/lib/util/time.m4
+++ /dev/null
@@ -1,9 +0,0 @@
-AC_CACHE_CHECK([if gettimeofday takes tz argument],samba_cv_HAVE_GETTIMEOFDAY_TZ,[
-AC_TRY_RUN([
-#include <sys/time.h>
-#include <unistd.h>
-main() { struct timeval tv; exit(gettimeofday(&tv, NULL));}],
-           samba_cv_HAVE_GETTIMEOFDAY_TZ=yes,samba_cv_HAVE_GETTIMEOFDAY_TZ=no,samba_cv_HAVE_GETTIMEOFDAY_TZ=yes)])
-if test x"$samba_cv_HAVE_GETTIMEOFDAY_TZ" = x"yes"; then
-    AC_DEFINE(HAVE_GETTIMEOFDAY_TZ,1,[Whether gettimeofday() is available])
-fi
diff --git a/source3/client/client.c b/source3/client/client.c
index 6e5e430..36cb112 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -1013,7 +1013,7 @@ static int do_get(const char *rname, const char *lname_in, bool reget)
 	int handle = 0;
 	uint16_t fnum;
 	bool newhandle = false;
-	struct timeval tp_start;
+	struct timespec tp_start;
 	uint16 attr;
 	SMB_OFF_T size;
 	off_t start = 0;
@@ -1038,7 +1038,7 @@ static int do_get(const char *rname, const char *lname_in, bool reget)
 		return 1;
 	}
 
-	GetTimeOfDay(&tp_start);
+	clock_gettime_mono(&tp_start);
 
 	if (!NT_STATUS_IS_OK(cli_open(targetcli, targetname, O_RDONLY, DENY_NONE, &fnum))) {
 		d_printf("%s opening remote file %s\n",cli_errstr(cli),rname);
@@ -1102,13 +1102,11 @@ static int do_get(const char *rname, const char *lname_in, bool reget)
 	}
 
 	{
-		struct timeval tp_end;
+		struct timespec tp_end;
 		int this_time;
 
-		GetTimeOfDay(&tp_end);
-		this_time =
-			(tp_end.tv_sec - tp_start.tv_sec)*1000 +
-			(tp_end.tv_usec - tp_start.tv_usec)/1000;
+		clock_gettime_mono(&tp_end);
+		this_time = TspecDiff(&tp_start,&tp_end);
 		get_total_time_ms += this_time;
 		get_total_size += nread;
 
@@ -1664,7 +1662,7 @@ static int do_put(const char *rname, const char *lname, bool reput)
 	XFILE *f;
 	SMB_OFF_T start = 0;
 	int rc = 0;
-	struct timeval tp_start;
+	struct timespec tp_start;
 	struct cli_state *targetcli;
 	char *targetname = NULL;
 	struct push_state state;
@@ -1675,7 +1673,7 @@ static int do_put(const char *rname, const char *lname, bool reput)
 		return 1;
 	}
 
-	GetTimeOfDay(&tp_start);
+	clock_gettime_mono(&tp_start);
 
 	if (reput) {
 		status = cli_open(targetcli, targetname, O_RDWR|O_CREAT, DENY_NONE, &fnum);
@@ -1747,13 +1745,11 @@ static int do_put(const char *rname, const char *lname, bool reput)
 	}
 
 	{
-		struct timeval tp_end;
+		struct timespec tp_end;
 		int this_time;
 
-		GetTimeOfDay(&tp_end);
-		this_time =
-			(tp_end.tv_sec - tp_start.tv_sec)*1000 +
-			(tp_end.tv_usec - tp_start.tv_usec)/1000;
+		clock_gettime_mono(&tp_end);
+		this_time = TspecDiff(&tp_start,&tp_end);
 		put_total_time_ms += this_time;
 		put_total_size += state.nread;
 
@@ -4482,9 +4478,11 @@ static void readline_callback(void)
 	fd_set fds;
 	struct timeval timeout;
 	static time_t last_t;
+	struct timespec now;
 	time_t t;
 
-	t = time(NULL);
+	clock_gettime_mono(&now);
+	t = now.tv_sec;
 
 	if (t - last_t < 5)
 		return;
diff --git a/source3/client/clitar.c b/source3/client/clitar.c
index 16493ec..534b721 100644
--- a/source3/client/clitar.c
+++ b/source3/client/clitar.c
@@ -629,9 +629,9 @@ static void do_atar(const char *rname_in, char *lname,
 	char *rname = NULL;
 	TALLOC_CTX *ctx = talloc_stackframe();
 
-	struct timeval tp_start;
+	struct timespec tp_start;
 
-	GetTimeOfDay(&tp_start);
+	clock_gettime_mono(&tp_start);
 
 	data = SMB_MALLOC_ARRAY(char, read_size);
 	if (!data) {
@@ -768,15 +768,15 @@ static void do_atar(const char *rname_in, char *lname,
 	fnum = -1;
 
 	if (shallitime) {
-		struct timeval tp_end;
+		struct timespec tp_end;
 		int this_time;
 
 		/* if shallitime is true then we didn't skip */
 		if (tar_reset && !dry_run)
 			(void) do_setrattr(finfo.name, aARCH, ATTRRESET);
 
-		GetTimeOfDay(&tp_end);
-		this_time = (tp_end.tv_sec - tp_start.tv_sec)*1000 + (tp_end.tv_usec - tp_start.tv_usec)/1000;
+		clock_gettime_mono(&tp_end);
+		this_time = (tp_end.tv_sec - tp_start.tv_sec)*1000 + (tp_end.tv_nsec - tp_start.tv_nsec)/1000000;
 		get_total_time_ms += this_time;
 		get_total_size += finfo.size;
 
@@ -1165,13 +1165,13 @@ static char *get_longfilename(file_info2 finfo)
 static void do_tarput(void)
 {
 	file_info2 finfo;
-	struct timeval tp_start;
+	struct timespec tp_start;
 	char *longfilename = NULL, linkflag;
 	int skip = False;
 
 	ZERO_STRUCT(finfo);
 
-	GetTimeOfDay(&tp_start);
+	clock_gettime_mono(&tp_start);
 	DEBUG(5, ("RJS do_tarput called ...\n"));
 
 	buffer_p = tarbuf + tbufsiz;  /* init this to force first read */
diff --git a/source3/configure.in b/source3/configure.in
index d28524f..80cf05b 100644
--- a/source3/configure.in
+++ b/source3/configure.in
@@ -121,7 +121,6 @@ fi
 
 m4_include(../lib/socket_wrapper/config.m4)
 m4_include(../lib/nss_wrapper/config.m4)
-m4_include(../lib/util/time.m4)
 
 m4_include(m4/swat.m4)
 
@@ -2369,23 +2368,8 @@ if test x"$samba_cv_HAVE_FUNCTION_MACRO" = x"yes"; then
     AC_DEFINE(HAVE_FUNCTION_MACRO,1,[Whether there is a __FUNCTION__ macro])
 fi
 
-
-if test x"$samba_cv_WITH_PROFILE" = x"yes"; then
-
-    # On some systems (eg. Linux) librt can pull in libpthread. We
-    # don't want this to happen because libpthreads changes signal delivery
-    # semantics in ways we are not prepared for. This breaks Linux oplocks
-    # which rely on signals.
-
-    AC_LIBTESTFUNC(rt, clock_gettime,
-	    [
-			    AC_DEFINE(HAVE_CLOCK_GETTIME, 1,
-				[Whether clock_gettime is available])
-			    SMB_CHECK_CLOCK_ID(CLOCK_MONOTONIC)
-			    SMB_CHECK_CLOCK_ID(CLOCK_PROCESS_CPUTIME_ID)
-			    SMB_CHECK_CLOCK_ID(CLOCK_REALTIME)
-			])
-
+if test x"$libreplace_cv_HAVE_CLOCK_GETTIME_IN_LIBRT" = xyes ; then
+	LIBS="$LIBS -lrt"
 fi
 
 AC_CACHE_CHECK([for broken readdir name],samba_cv_HAVE_BROKEN_READDIR_NAME,[
diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h
index 757c8a2..e72f2aa 100644
--- a/source3/include/smb_macros.h
+++ b/source3/include/smb_macros.h
@@ -153,6 +153,15 @@ values
   (((tvalnew)->tv_sec - (tvalold)->tv_sec)*1000 +  \
 	 ((int)(tvalnew)->tv_usec - (int)(tvalold)->tv_usec)/1000)
 
+/*******************************************************************
+find the difference in milliseconds between two struct timespec
+values
+********************************************************************/
+
+#define TspecDiff(tvalold,tvalnew) \
+  (((tvalnew)->tv_sec - (tvalold)->tv_sec)*1000 +  \
+	 ((int)(tvalnew)->tv_nsec - (int)(tvalold)->tv_nsec)/1000000)
+
 /****************************************************************************
 true if two IPv4 addresses are equal
 ****************************************************************************/
diff --git a/source3/include/smbprofile.h b/source3/include/smbprofile.h
index e9015ff..6076479 100644
--- a/source3/include/smbprofile.h
+++ b/source3/include/smbprofile.h
@@ -894,8 +894,6 @@ extern bool do_profile_times;
 #define DEC_PROFILE_COUNT(x) profile_p->x--
 #define ADD_PROFILE_COUNT(x,y) profile_p->x += (y)
 
-#if defined(HAVE_CLOCK_GETTIME)
-
 extern clockid_t __profile_clock;
 
 static inline uint64_t profile_timestamp(void)
@@ -911,17 +909,6 @@ static inline uint64_t profile_timestamp(void)
 	return (ts.tv_sec * 1000000) + (ts.tv_nsec / 1000); /* usec */
 }
 
-#else
-
-static inline uint64_t profile_timestamp(void)
-{
-	struct timeval tv;
-	GetTimeOfDay(&tv);
-	return (tv.tv_sec * 1000000) + tv.tv_usec;
-}


-- 
Samba Shared Repository


More information about the samba-cvs mailing list