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

Grant Grundler iod00d at hp.com
Tue May 10 18:40:14 PDT 2005


Hi Michael,
Patch below fixes up the Makefile and getclock.h so C code is in C files
like people expect.

Unfortunately, I don't know how to make svn diff treat a new file as
part of the diff.  "cvs -upN" is how I would do it for cvs.
svn just (correctly) whines it doesn't know about the new file.

But it's easy to generate get_clock.c:
	cp get_clock.h get_clock.c
	edit get_clock.c and delete everything related to get_cycles().
	(This preserves the copyright/license too)

*THEN* apply the patch below.

thanks,
grant


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 2296)
+++ 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)



More information about the general mailing list