profile.h (49c871278a2004345c7abbdc1ef0a560121b6c06) | 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("pushq %0; call __mcount; popq %%rcx" \ 65 : \ 66 : "i" (label) \ 67 : "cx", "r10", "r11", "memory") 68#define MEXITCOUNT_OVERHEAD() \ 69 __asm __volatile("call .mexitcount; 1:" \ 70 : : \ 71 : "r10", "r11", "memory") 72#define MEXITCOUNT_OVERHEAD_GETLABEL(labelp) \ 73 __asm __volatile("movq $1b,%0" : "=rm" (labelp)) 74#else 75#error this file needs to be ported to your compiler 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); 95void user(void); 96 97#define MCOUNT_FROMPC_USER(pc) \ 98 ((pc < (uintfptr_t)VM_MAXUSER_ADDRESS) ? (uintfptr_t)user : pc) 99 100#define MCOUNT_FROMPC_INTR(pc) \ 101 ((pc >= (uintfptr_t)btrap && pc < (uintfptr_t)eintr) ? \ 102 ((pc >= (uintfptr_t)bintr) ? (uintfptr_t)bintr : \ 103 (uintfptr_t)btrap) : ~0UL) 104 105#else /* !_KERNEL */ 106 | |
107#define FUNCTION_ALIGNMENT 4 108 109#define _MCOUNT_DECL \ 110static void _mcount(uintfptr_t frompc, uintfptr_t selfpc) __used; \ 111static void _mcount 112 113#ifdef __GNUCLIKE_ASM 114#define MCOUNT __asm(" \n\ --- 52 unchanged lines hidden (view full) --- 167} 168#endif 169#else /* !__GNUCLIKE_ASM */ 170#define MCOUNT 171#endif /* __GNUCLIKE_ASM */ 172 173typedef u_long uintfptr_t; 174 | 42#define FUNCTION_ALIGNMENT 4 43 44#define _MCOUNT_DECL \ 45static void _mcount(uintfptr_t frompc, uintfptr_t selfpc) __used; \ 46static void _mcount 47 48#ifdef __GNUCLIKE_ASM 49#define MCOUNT __asm(" \n\ --- 52 unchanged lines hidden (view full) --- 102} 103#endif 104#else /* !__GNUCLIKE_ASM */ 105#define MCOUNT 106#endif /* __GNUCLIKE_ASM */ 107 108typedef u_long uintfptr_t; 109 |
175#endif /* _KERNEL */ 176 | |
177/* 178 * An unsigned integral type that can hold non-negative difference between 179 * function pointers. 180 */ 181typedef u_long fptrdiff_t; 182 | 110/* 111 * An unsigned integral type that can hold non-negative difference between 112 * function pointers. 113 */ 114typedef u_long fptrdiff_t; 115 |
183#ifdef _KERNEL 184 185void mcount(uintfptr_t frompc, uintfptr_t selfpc); 186 187#else /* !_KERNEL */ 188 189#include <sys/cdefs.h> 190 | |
191__BEGIN_DECLS 192#ifdef __GNUCLIKE_ASM 193void mcount(void) __asm(".mcount"); 194#endif 195__END_DECLS 196 | 116__BEGIN_DECLS 117#ifdef __GNUCLIKE_ASM 118void mcount(void) __asm(".mcount"); 119#endif 120__END_DECLS 121 |
197#endif /* _KERNEL */ | 122#endif /* !_KERNEL */ |
198 199#endif /* !_MACHINE_PROFILE_H_ */ | 123 124#endif /* !_MACHINE_PROFILE_H_ */ |