[openib-general] Re: perftest-03: put C code in .c file

Grant Grundler iod00d at hp.com
Wed May 11 08:05:43 PDT 2005


On Wed, May 11, 2005 at 09:38:09AM +0300, Michael S. Tsirkin wrote:
> You have to svn add before svn diff -x --diff-cmd=/usr/bin/diff -x -upN

certainly - Appended below

> Grant, could you please resend, while also adding a Signed-off-by line?

I've been ommitting the S-o-B line since I realized this isn't kernel code.
I'm happy to include them if you like.

Can we follow Documentation/Codingstyle too?

thanks,
grant


Signed-off-by: Grant Grundler <iod00d at hp.com>

diff -u get_clock.h get_clock.h
--- get_clock.h	(working copy)
+++ get_clock.h	(working copy)
@@ -32,9 +32,6 @@
  * $Id$
  */
 
-#include <unistd.h>
-#include <stdio.h>
-
 #if defined (__x86_64__) || defined(__i386__)
 typedef unsigned long long cycles_t;
 static inline cycles_t get_clock()
@@ -71,29 +68,2 @@
-double get_cpu_mhz()
-{
-	FILE* f;
-	char buf[256];
-	double mhz = 0.0;
-
-	f = fopen("/proc/cpuinfo","r");
-	if (!f)
-		return 0.0;
-	while(fgets(buf, sizeof(buf), f)) {
-		double m;
-		int rc;
-		rc = sscanf(buf, "cpu MHz : %lf", &m);
-		if (rc != 1)
-			continue;
-		if (mhz == 0.0) {
-			mhz = m;
-			continue;
-		}
-		if (mhz != m) {
-			fprintf(stderr,"Conflicting CPU frequency values "
-					" detected: %lf != %lf\n",
-					mhz, m);
-			return 0.0;
-		}
-	}
-	fclose(f);
-	return mhz;
-}
+
+extern double get_cpu_mhz(void);
only in patch2:
unchanged:
--- Makefile	(revision 2302)
+++ Makefile	(working copy)
@@ -1,6 +1,9 @@
 CFLAGS = -Wall -O2 -g -D_GNU_SOURCE 
 
-rdma_lat: rdma_lat.c get_clock.h
-	gcc $(CFLAGS) -o rdma_lat rdma_lat.c -libverbs
+RDMA_LAT_OBJ = rdma_lat.o get_clock.o
+
+rdma_lat: $(RDMA_LAT_OBJ)
+	gcc -o rdma_lat $(RDMA_LAT_OBJ) -libverbs
+
 clean:
-	rm -f rdma_lat
+	rm -f rdma_lat $(RDMA_LAT_OBJ)
--- get_clock.c	(revision 0)
+++ get_clock.c	(revision 0)
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2005 Mellanox Technologies Ltd.  All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * $Id$
+ */
+
+#include <unistd.h>
+#include <stdio.h>
+
+double get_cpu_mhz()
+{
+	FILE* f;
+	char buf[256];
+	double mhz = 0.0;
+
+	f = fopen("/proc/cpuinfo","r");
+	if (!f)
+		return 0.0;
+	while(fgets(buf, sizeof(buf), f)) {
+		double m;
+		int rc;
+		rc = sscanf(buf, "cpu MHz : %lf", &m);
+		if (rc != 1)
+			continue;
+		if (mhz == 0.0) {
+			mhz = m;
+			continue;
+		}
+		if (mhz != m) {
+			fprintf(stderr,"Conflicting CPU frequency values "
+					" detected: %lf != %lf\n",
+					mhz, m);
+			return 0.0;
+		}
+	}
+	fclose(f);
+	return mhz;
+}



More information about the general mailing list