profile.h (d10566cf499af9394e369cb07a4844d1552ef0cf) profile.h (aa3ea612be3659881392251e91912682b038ce78)
1/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 1992, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 21 unchanged lines hidden (view full) ---

30 *
31 * @(#)profile.h 8.1 (Berkeley) 6/11/93
32 * $FreeBSD$
33 */
34
35#ifndef _MACHINE_PROFILE_H_
36#define _MACHINE_PROFILE_H_
37
1/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 1992, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 21 unchanged lines hidden (view full) ---

30 *
31 * @(#)profile.h 8.1 (Berkeley) 6/11/93
32 * $FreeBSD$
33 */
34
35#ifndef _MACHINE_PROFILE_H_
36#define _MACHINE_PROFILE_H_
37
38#ifndef _SYS_CDEFS_H_
39#error this file needs sys/cdefs.h as a prerequisite
40#endif
38#ifndef _KERNEL
41
39
42#ifdef _KERNEL
40#include <sys/cdefs.h>
43
41
44/*
45 * Config generates something to tell the compiler to align functions on 16
46 * byte boundaries. A strict alignment is good for keeping the tables small.
47 */
48#define FUNCTION_ALIGNMENT 16
49
50/*
51 * The kernel uses assembler stubs instead of unportable inlines.
52 * This is mainly to save a little time when profiling is not enabled,
53 * which is the usual case for the kernel.
54 */
55#define _MCOUNT_DECL void mcount
56#define MCOUNT
57
58#ifdef GUPROF
59#define MCOUNT_DECL(s)
60#define MCOUNT_ENTER(s)
61#define MCOUNT_EXIT(s)
62#ifdef __GNUCLIKE_ASM
63#define MCOUNT_OVERHEAD(label) \
64 __asm __volatile("pushl %0; call __mcount; popl %%ecx" \
65 : \
66 : "i" (label) \
67 : "ax", "dx", "cx", "memory")
68#define MEXITCOUNT_OVERHEAD() \
69 __asm __volatile("call .mexitcount; 1:" \
70 : : \
71 : "cx", "memory")
72#define MEXITCOUNT_OVERHEAD_GETLABEL(labelp) \
73 __asm __volatile("movl $1b,%0" : "=rm" (labelp))
74#else
75#error
76#endif /* !__GNUCLIKE_ASM */
77#else /* !GUPROF */
78#define MCOUNT_DECL(s) register_t s;
79#ifdef SMP
80extern int mcount_lock;
81#define MCOUNT_ENTER(s) { s = intr_disable(); \
82 while (!atomic_cmpset_acq_int(&mcount_lock, 0, 1)) \
83 /* nothing */ ; }
84#define MCOUNT_EXIT(s) { atomic_store_rel_int(&mcount_lock, 0); \
85 intr_restore(s); }
86#else
87#define MCOUNT_ENTER(s) { s = intr_disable(); }
88#define MCOUNT_EXIT(s) (intr_restore(s))
89#endif
90#endif /* GUPROF */
91
92void bintr(void);
93void btrap(void);
94void eintr(void);
95#if 0
96void end_exceptions(void);
97void start_exceptions(void);
98#else
99#include <machine/pmc_mdep.h> /* XXX */
100#endif
101void user(void);
102
103#include <machine/md_var.h> /* XXX for setidt_disp */
104
105#define MCOUNT_DETRAMP(pc) do { \
106 if ((pc) >= (uintfptr_t)start_exceptions + setidt_disp && \
107 (pc) < (uintfptr_t)end_exceptions + setidt_disp) \
108 (pc) -= setidt_disp; \
109} while (0)
110
111#define MCOUNT_FROMPC_INTR(pc) \
112 ((pc >= (uintfptr_t)btrap && pc < (uintfptr_t)eintr) ? \
113 ((pc >= (uintfptr_t)bintr) ? (uintfptr_t)bintr : \
114 (uintfptr_t)btrap) : ~0U)
115
116#define MCOUNT_USERPC ((uintfptr_t)user)
117
118#else /* !_KERNEL */
119
120#define FUNCTION_ALIGNMENT 4
121
122#define _MCOUNT_DECL static __inline void _mcount
123
124#ifdef __GNUCLIKE_ASM
125#define MCOUNT \
126void \
127mcount() \

--- 26 unchanged lines hidden (view full) ---

154 __asm("" : : "c" (ecx)); \
155}
156#else /* !__GNUCLIKE_ASM */
157#define MCOUNT
158#endif /* __GNUCLIKE_ASM */
159
160typedef u_int uintfptr_t;
161
42#define FUNCTION_ALIGNMENT 4
43
44#define _MCOUNT_DECL static __inline void _mcount
45
46#ifdef __GNUCLIKE_ASM
47#define MCOUNT \
48void \
49mcount() \

--- 26 unchanged lines hidden (view full) ---

76 __asm("" : : "c" (ecx)); \
77}
78#else /* !__GNUCLIKE_ASM */
79#define MCOUNT
80#endif /* __GNUCLIKE_ASM */
81
82typedef u_int uintfptr_t;
83
162#endif /* _KERNEL */
163
164/*
165 * An unsigned integral type that can hold non-negative difference between
166 * function pointers.
167 */
168typedef u_int fptrdiff_t;
169
84/*
85 * An unsigned integral type that can hold non-negative difference between
86 * function pointers.
87 */
88typedef u_int fptrdiff_t;
89
170#ifdef _KERNEL
171
172void mcount(uintfptr_t frompc, uintfptr_t selfpc);
173
174#else /* !_KERNEL */
175
176#include <sys/cdefs.h>
177
178__BEGIN_DECLS
179#ifdef __GNUCLIKE_ASM
180void mcount(void) __asm(".mcount");
181#endif
182__END_DECLS
183
90__BEGIN_DECLS
91#ifdef __GNUCLIKE_ASM
92void mcount(void) __asm(".mcount");
93#endif
94__END_DECLS
95
184#endif /* _KERNEL */
96#endif /* !_KERNEL */
185
186#endif /* !_MACHINE_PROFILE_H_ */
97
98#endif /* !_MACHINE_PROFILE_H_ */