about summary refs log tree commit diff
path: root/sysdeps/generic/prof-freq.c
diff options
context:
space:
mode:
authorThomas Bushnell, BSG <thomas@gnu.org>1996-09-06 00:08:55 +0000
committerThomas Bushnell, BSG <thomas@gnu.org>1996-09-06 00:08:55 +0000
commitacf51e02617b9b8da57b0ee982f96080ee954a38 (patch)
treea656620596b189465593e06b89fb31478dbcf2f3 /sysdeps/generic/prof-freq.c
parent57ba7bb47152ed3e50805db2bca137cb866a9a71 (diff)
downloadglibc-acf51e02617b9b8da57b0ee982f96080ee954a38.tar.gz
glibc-acf51e02617b9b8da57b0ee982f96080ee954a38.tar.xz
glibc-acf51e02617b9b8da57b0ee982f96080ee954a38.zip
*** empty log message *** cvs/libc-960906
Thu Sep  5 13:18:25 1996  Thomas Bushnell, n/BSG  <thomas@gnu.ai.mit.edu>

	* sysdeps/mach/hurd/i386/init-first.c (__libc_argc, __libc_argv):
	New variables.
	(init1): Initialize them.
	* hurd/hurdinit.c (_hurd_setproc): Now that happens to be
	available, pass __libc_argv in call to __proc_set_arg_locations.

	* gmon/gmon.c (write_hist): Call __profile_frequency instead of
	hertz. 
	(hertz): Delete function.
	* gmon/Makefile (routines): Add `prof-freq'.
	* sysdeps/generic/prof-freq.c: New file.
	* sysdeps/mach/hurd/prof-freq.c: New (stubby) file.
	* sysdeps/mach/hurd/profil.c (profile_tick): New variable.
	(update_waiter): Store frequency in profile_tick.
	(__profile_frequency): New function.

	* sysdeps/mach/hurd/sendto.c (sendto): Use prototype definition
	syntax.

	* Rules (generated): Restore reference to $(generated).

	* mach/Machrules (mig.uh, mig.__h): Don't include $(user-MIGFLAGS)
	here. 

 	* malloc/free.c (free): __lib_malloc_lock -> __libc_malloc_lock.
	
	* malloc/free.c: Provide extern decl of __libc_malloc_lock.
	* malloc/realloc.c: Likewise.
	* malloc/malloc-find.c: Likewise.
	* malloc/malloc-size.c: Likewise.
	* malloc/malloc-walk.c: Likewise.
	* malloc/memalign.c: Likewise.

  	* mach/Machrules (mig.uh, mig.__h): Include $(user-MIGFLAGS) and
Diffstat (limited to 'sysdeps/generic/prof-freq.c')
-rw-r--r--sysdeps/generic/prof-freq.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/sysdeps/generic/prof-freq.c b/sysdeps/generic/prof-freq.c
new file mode 100644
index 0000000000..4e952e781d
--- /dev/null
+++ b/sysdeps/generic/prof-freq.c
@@ -0,0 +1,59 @@
+/* Return frequency of ticks reported by profil.  Generic version. */
+/*-
+ * Copyright (c) 1983, 1992, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+
+#include <sys/types.h>
+#include <sys/time.h>
+
+int
+__profile_frequency ()
+{
+  /*
+   * Discover the tick frequency of the machine if something goes wrong,
+   * we return 0, an impossible hertz.
+   */
+  struct itimerval tim;
+
+  tim.it_interval.tv_sec = 0;
+  tim.it_interval.tv_usec = 1;
+  tim.it_value.tv_sec = 0;
+  tim.it_value.tv_usec = 0;
+  setitimer(ITIMER_REAL, &tim, 0);
+  setitimer(ITIMER_REAL, 0, &tim);
+  if (tim.it_interval.tv_usec < 2)
+    return 0;
+  return (1000000 / tim.it_interval.tv_usec);
+}
+
+