1 | /* $Id: highpc.c,v 1.1 2000-02-29 00:50:04 sandervl Exp $ */
|
---|
2 |
|
---|
3 | /*
|
---|
4 | * Mesa 3-D graphics library
|
---|
5 | * Version: 3.1
|
---|
6 | *
|
---|
7 | * Copyright (C) 1999 Brian Paul All Rights Reserved.
|
---|
8 | *
|
---|
9 | * Permission is hereby granted, free of charge, to any person obtaining a
|
---|
10 | * copy of this software and associated documentation files (the "Software"),
|
---|
11 | * to deal in the Software without restriction, including without limitation
|
---|
12 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
---|
13 | * and/or sell copies of the Software, and to permit persons to whom the
|
---|
14 | * Software is furnished to do so, subject to the following conditions:
|
---|
15 | *
|
---|
16 | * The above copyright notice and this permission notice shall be included
|
---|
17 | * in all copies or substantial portions of the Software.
|
---|
18 | *
|
---|
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
---|
20 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
---|
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
---|
22 | * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
---|
23 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
---|
24 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
---|
25 | */
|
---|
26 |
|
---|
27 | #ifndef XFree86Server
|
---|
28 | #include <stdio.h>
|
---|
29 | #include <stdlib.h>
|
---|
30 | #else
|
---|
31 | #include "GL/xf86glx.h"
|
---|
32 | #endif
|
---|
33 | #include "types.h" /* for MESA_VERBOSE */
|
---|
34 |
|
---|
35 |
|
---|
36 | /*
|
---|
37 | * This is the highest address in Mesa
|
---|
38 | */
|
---|
39 | void mesa_highpc(void) { }
|
---|
40 |
|
---|
41 | #if defined(__GNUC__) && defined(__linux__)
|
---|
42 |
|
---|
43 | void monstartup( char *lowpc, char *highpc );
|
---|
44 | void _mcleanup( void );
|
---|
45 | void mesa_lowpc( void );
|
---|
46 | void mesa_highpc( void );
|
---|
47 |
|
---|
48 | static int profile = 0;
|
---|
49 |
|
---|
50 | void force_init_prof( void )
|
---|
51 | {
|
---|
52 | FILE *fp;
|
---|
53 |
|
---|
54 | if (profile) return;
|
---|
55 |
|
---|
56 | profile = 1;
|
---|
57 |
|
---|
58 | monstartup( (char *)mesa_lowpc, (char *)mesa_highpc );
|
---|
59 |
|
---|
60 | fprintf(stderr, "Starting profiling, %x %x\n",
|
---|
61 | (unsigned int)mesa_lowpc,
|
---|
62 | (unsigned int)mesa_highpc);
|
---|
63 |
|
---|
64 | if ((fp = fopen( "mesa_lowpc", "w" )) != NULL) {
|
---|
65 | fprintf( fp, "0x%08x ", (unsigned int)mesa_lowpc );
|
---|
66 | fclose( fp );
|
---|
67 | }
|
---|
68 | }
|
---|
69 |
|
---|
70 | /*
|
---|
71 | * Start profiling
|
---|
72 | */
|
---|
73 | void __attribute__ ((constructor))
|
---|
74 | init_prof( void )
|
---|
75 | {
|
---|
76 | FILE *fp;
|
---|
77 | char *s = getenv("MESA_MON");
|
---|
78 |
|
---|
79 | if (s == NULL || atoi(s) == 0)
|
---|
80 | return;
|
---|
81 |
|
---|
82 | profile = 1;
|
---|
83 |
|
---|
84 | monstartup( (char *)mesa_lowpc, (char *)mesa_highpc );
|
---|
85 |
|
---|
86 | fprintf(stderr, "Starting profiling, %x %x\n",
|
---|
87 | (unsigned int)mesa_lowpc,
|
---|
88 | (unsigned int)mesa_highpc);
|
---|
89 |
|
---|
90 | if ((fp = fopen( "mesa_lowpc", "w" )) != NULL) {
|
---|
91 | fprintf( fp, "0x%08x ", (unsigned int)mesa_lowpc );
|
---|
92 | fclose( fp );
|
---|
93 | }
|
---|
94 | }
|
---|
95 |
|
---|
96 |
|
---|
97 |
|
---|
98 | /*
|
---|
99 | * Finish profiling
|
---|
100 | */
|
---|
101 | void __attribute__ ((destructor))
|
---|
102 | fini_prof( void )
|
---|
103 | {
|
---|
104 | if (profile) {
|
---|
105 | _mcleanup( );
|
---|
106 |
|
---|
107 | fprintf(stderr, "Finished profiling\n");
|
---|
108 | }
|
---|
109 | }
|
---|
110 |
|
---|
111 | #else
|
---|
112 |
|
---|
113 | void force_init_prof( void )
|
---|
114 | {
|
---|
115 | }
|
---|
116 |
|
---|
117 | #endif
|
---|