Mon Jan 5 18:06:57 2009 UTC ()
Temporarily define MCOUNT as a dummy for _RUMPKERNEL to allow build
to proceed - the MD macros use processor instructions unavailable
to userspace and should/could be provided as interfaces.


(pooka)
diff -r1.7 -r1.8 src/common/lib/libc/gmon/mcount.c

cvs diff -r1.7 -r1.8 src/common/lib/libc/gmon/mcount.c (expand / switch to unified diff)

--- src/common/lib/libc/gmon/mcount.c 2006/10/27 22:14:13 1.7
+++ src/common/lib/libc/gmon/mcount.c 2009/01/05 18:06:57 1.8
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: mcount.c,v 1.7 2006/10/27 22:14:13 uwe Exp $ */ 1/* $NetBSD: mcount.c,v 1.8 2009/01/05 18:06:57 pooka Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2003, 2004 Wasabi Systems, Inc. 4 * Copyright (c) 2003, 2004 Wasabi Systems, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Written by Nathan J. Williams for Wasabi Systems, Inc. 7 * Written by Nathan J. Williams for Wasabi Systems, Inc.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
@@ -66,72 +66,82 @@ @@ -66,72 +66,82 @@
66 66
67/* If building a standalone libkern, don't include mcount. */ 67/* If building a standalone libkern, don't include mcount. */
68#if (!defined(_KERNEL) || defined(GPROF)) && !defined(_STANDALONE) 68#if (!defined(_KERNEL) || defined(GPROF)) && !defined(_STANDALONE)
69 69
70#ifdef _KERNEL_OPT 70#ifdef _KERNEL_OPT
71#include "opt_multiprocessor.h" 71#include "opt_multiprocessor.h"
72#endif 72#endif
73 73
74#include <sys/cdefs.h> 74#include <sys/cdefs.h>
75#if !defined(lint) && !defined(_KERNEL) && defined(LIBC_SCCS) 75#if !defined(lint) && !defined(_KERNEL) && defined(LIBC_SCCS)
76#if 0 76#if 0
77static char sccsid[] = "@(#)mcount.c 8.1 (Berkeley) 6/4/93"; 77static char sccsid[] = "@(#)mcount.c 8.1 (Berkeley) 6/4/93";
78#else 78#else
79__RCSID("$NetBSD: mcount.c,v 1.7 2006/10/27 22:14:13 uwe Exp $"); 79__RCSID("$NetBSD: mcount.c,v 1.8 2009/01/05 18:06:57 pooka Exp $");
80#endif 80#endif
81#endif 81#endif
82 82
83#include <sys/param.h> 83#include <sys/param.h>
84#include <sys/gmon.h> 84#include <sys/gmon.h>
85 85
86#ifndef _KERNEL 86#ifndef _KERNEL
87#include "reentrant.h" 87#include "reentrant.h"
88#endif 88#endif
89 89
90#ifdef _REENTRANT 90#ifdef _REENTRANT
91extern thread_key_t _gmonkey; 91extern thread_key_t _gmonkey;
92extern struct gmonparam _gmondummy; 92extern struct gmonparam _gmondummy;
93struct gmonparam *_m_gmon_alloc(void); 93struct gmonparam *_m_gmon_alloc(void);
94#endif 94#endif
95 95
96_MCOUNT_DECL __P((u_long, u_long)) 96_MCOUNT_DECL __P((u_long, u_long))
97#ifdef _KERNEL 97#ifdef _KERNEL
98 __attribute__((__no_instrument_function__)) 98 __attribute__((__no_instrument_function__))
99#endif 99#endif
100 __used; 100 __used;
101 101
 102/* XXX: make these interfaces */
 103#ifdef _RUMPKERNEL
 104#undef MCOUNT_ENTER
 105#define MCOUNT_ENTER
 106#undef MCOUNT_EXIT
 107#define MCOUNT_EXIT
 108#undef MCOUNT
 109#define MCOUNT
 110#endif
 111
102/* 112/*
103 * mcount is called on entry to each function compiled with the profiling 113 * mcount is called on entry to each function compiled with the profiling
104 * switch set. _mcount(), which is declared in a machine-dependent way 114 * switch set. _mcount(), which is declared in a machine-dependent way
105 * with _MCOUNT_DECL, does the actual work and is either inlined into a 115 * with _MCOUNT_DECL, does the actual work and is either inlined into a
106 * C routine or called by an assembly stub. In any case, this magic is 116 * C routine or called by an assembly stub. In any case, this magic is
107 * taken care of by the MCOUNT definition in <machine/profile.h>. 117 * taken care of by the MCOUNT definition in <machine/profile.h>.
108 * 118 *
109 * _mcount updates data structures that represent traversals of the 119 * _mcount updates data structures that represent traversals of the
110 * program's call graph edges. frompc and selfpc are the return 120 * program's call graph edges. frompc and selfpc are the return
111 * address and function address that represents the given call graph edge. 121 * address and function address that represents the given call graph edge.
112 *  122 *
113 * Note: the original BSD code used the same variable (frompcindex) for 123 * Note: the original BSD code used the same variable (frompcindex) for
114 * both frompcindex and frompc. Any reasonable, modern compiler will 124 * both frompcindex and frompc. Any reasonable, modern compiler will
115 * perform this optimization. 125 * perform this optimization.
116 */ 126 */
117_MCOUNT_DECL(frompc, selfpc) /* _mcount; may be static, inline, etc */ 127_MCOUNT_DECL(frompc, selfpc) /* _mcount; may be static, inline, etc */
118 u_long frompc, selfpc; 128 u_long frompc, selfpc;
119{ 129{
120 u_short *frompcindex; 130 u_short *frompcindex;
121 struct tostruct *top, *prevtop; 131 struct tostruct *top, *prevtop;
122 struct gmonparam *p; 132 struct gmonparam *p;
123 long toindex; 133 long toindex;
124#ifdef _KERNEL 134#if defined(_KERNEL) && !defined(_RUMPKERNEL)
125 int s; 135 int s;
126#endif 136#endif
127 137
128#if defined(_REENTRANT) && !defined(_KERNEL) 138#if defined(_REENTRANT) && !defined(_KERNEL)
129 if (__isthreaded) { 139 if (__isthreaded) {
130 p = thr_getspecific(_gmonkey); 140 p = thr_getspecific(_gmonkey);
131 if (p == NULL) { 141 if (p == NULL) {
132 /* Prevent recursive calls while allocating */ 142 /* Prevent recursive calls while allocating */
133 thr_setspecific(_gmonkey, &_gmondummy); 143 thr_setspecific(_gmonkey, &_gmondummy);
134 p = _m_gmon_alloc(); 144 p = _m_gmon_alloc();
135 } 145 }
136 } else 146 } else
137#endif 147#endif