diff -urN /tmp/libpfm-3.1.orig/ChangeLog libpfm-3.1/ChangeLog
--- /tmp/libpfm-3.1.orig/ChangeLog	2004-12-21 06:40:20.000000000 -0800
+++ libpfm-3.1/ChangeLog	2005-04-25 12:51:21.000000000 -0700
@@ -1,3 +1,9 @@
+2005-04-25 Stephane Eranian <eranian@hpl.hp.com>
+	* examples/multiplex.c: print correct scaled results (patch already posted)
+	* lib/pfmlib_common.c : fix pfm_print_event_info to avoid pfmon -i0x50 bug
+	* Makefile: switch CC to gcc and not icc
+	* lib/pfmlib_itanium2.c: fix code range restriction problem in pfm_dispatch_irange()
+
 2004-12-21 Stephane Eranian <eranian@hpl.hp.com>
 	* updated task_smpl.c for CLOEXEC
 
Binary files /tmp/libpfm-3.1.orig/.ChangeLog.swp and libpfm-3.1/.ChangeLog.swp differ
diff -urN /tmp/libpfm-3.1.orig/config.mk libpfm-3.1/config.mk
--- /tmp/libpfm-3.1.orig/config.mk	2004-12-21 06:14:58.000000000 -0800
+++ libpfm-3.1/config.mk	2005-04-21 04:48:54.000000000 -0700
@@ -58,8 +58,8 @@
 # ecc the Intel Itanium Compiler (7.x or 8.x)
 # gcc-3.2, 3.4, 3.1
 #
-CC=icc
-#CC=gcc -Wall
+#CC=icc
+CC=gcc -Wall
 
 CFLAGS=$(OPTIM) -g $(CONFIG_FLAGS)
 LDFLAGS=-L$(TOPDIR)/libpfm
diff -urN /tmp/libpfm-3.1.orig/examples/multiplex.c libpfm-3.1/examples/multiplex.c
--- /tmp/libpfm-3.1.orig/examples/multiplex.c	2004-12-21 05:14:07.000000000 -0800
+++ libpfm-3.1/examples/multiplex.c	2005-04-17 03:00:28.000000000 -0700
@@ -272,7 +272,7 @@
 {
 	unsigned int i, j;
 	event_set_t *e;
-	char tmp[32];
+	char tmp1[32], tmp2[32];
 	char mtotal_str[32], *mtotal;
 	char stotal_str[32], *stotal;
 
@@ -286,6 +286,7 @@
  	*/
 	printf("%lu Hz period = %lu cycles @ %lu Mhz\n", options.smpl_freq, options.smpl_period, options.cpu_mhz);
 	printf("%lu full periods\n", options.full_periods);
+	printf("%lu event sets\n", N_SETS);
 	printf("set        measured total     #runs         scaled total event name\n");
 	printf("-------------------------------------------------------------------\n");
 
@@ -293,21 +294,21 @@
 		e = events + i;
 		for(j=0; j < e->n_counters-1; j++) {
 
-			sprintf(tmp, "%"PRIu64, e->values[j]);
+			sprintf(tmp1, "%"PRIu64, e->values[j]);
 
 			if (options.opt_us_format) {
-				dec2sep(tmp, mtotal_str, ',');
+				dec2sep(tmp1, mtotal_str, ',');
 				mtotal = mtotal_str;
 			} else {
-				mtotal  = tmp;
+				mtotal  = tmp1;
 			}
-			sprintf(tmp, "%"PRIu64, (e->values[j]*options.full_periods)/e->n_runs);  /* stupid scaling */
+			sprintf(tmp2, "%"PRIu64, (e->values[j]*options.full_periods)/e->n_runs);  /* stupid scaling */
 
 			if (options.opt_us_format) {
-				dec2sep(tmp, stotal_str, ',');
+				dec2sep(tmp2, stotal_str, ',');
 				stotal = stotal_str;
 			} else {
-				stotal  = tmp;
+				stotal  = tmp2;
 			}
 
 			printf("%03d: %20s  %8"PRIu64" %20s %s\n",
diff -urN /tmp/libpfm-3.1.orig/lib/pfmlib_common.c libpfm-3.1/lib/pfmlib_common.c
--- /tmp/libpfm-3.1.orig/lib/pfmlib_common.c	2004-12-21 03:33:40.000000000 -0800
+++ libpfm-3.1/lib/pfmlib_common.c	2005-04-25 12:43:03.000000000 -0700
@@ -396,7 +396,8 @@
 
 	if (name == NULL || pf == NULL) return PFMLIB_ERR_INVAL;
 
-	pfm_current->get_num_counters(&n);
+	pfm_current->get_num_counters(&num_counters);
+	pfm_current->get_impl_counters(&impl_counters);
 
 	/* we can't quite use pfm_findevent() because we need to try
 	 * both ways systematically.
@@ -424,7 +425,6 @@
 
 	if (ret != PFMLIB_SUCCESS) return PFMLIB_ERR_NOTFOUND;
 
-	pfm_current->get_num_counters(&num_counters);
 start_loop:
 	do {
 		code  = pfm_current->get_event_code(idx);
diff -urN /tmp/libpfm-3.1.orig/lib/pfmlib_itanium2.c libpfm-3.1/lib/pfmlib_itanium2.c
--- /tmp/libpfm-3.1.orig/lib/pfmlib_itanium2.c	2004-12-21 03:38:38.000000000 -0800
+++ libpfm-3.1/lib/pfmlib_itanium2.c	2005-04-25 06:55:40.000000000 -0700
@@ -229,7 +229,16 @@
 		pfm_get_event_code(inp->pfp_events[i].event, &c);
 		if (c == code)  {
 			pfm_ita2_get_event_umask(inp->pfp_events[i].event, &umask);
-			mask |= umask;
+			switch(umask) {
+				case 0: mask |= 1;
+					break;
+				case 1: mask |= 2;
+					break;
+				case 2: mask |= 4;
+					break;
+				case 3: mask |= 8;
+					break;
+			}
 			found++;
 		}
 	}
@@ -1449,15 +1458,14 @@
 	if (fine_mode) {
 		reg.pmc14_ita2_reg.iarc_fine = 1;
 	} else if (retired_only) {
-		unsigned long m;
 		/*
 		 * we need to check that the user provided all the events needed to cover
 		 * all the ibr pairs used to cover the range
 		 */
-		for(i=0; i < 4; i++) {
-			m = 1UL << i;
-			if ((reg.pmc_val & m) && (retired_mask & m) == 0) return PFMLIB_ERR_IRRINVAL;
-		}
+		if ((retired_mask & 0x1) == 0 &&  reg.pmc14_ita2_reg.iarc_ibrp0 == 0) return PFMLIB_ERR_IRRINVAL;
+		if ((retired_mask & 0x2) == 0 &&  reg.pmc14_ita2_reg.iarc_ibrp1 == 0) return PFMLIB_ERR_IRRINVAL;
+		if ((retired_mask & 0x4) == 0 &&  reg.pmc14_ita2_reg.iarc_ibrp2 == 0) return PFMLIB_ERR_IRRINVAL;
+		if ((retired_mask & 0x8) == 0 &&  reg.pmc14_ita2_reg.iarc_ibrp3 == 0) return PFMLIB_ERR_IRRINVAL;
 	}
 
 	/* initialize pmc request slot */

