| 1 | /* $Id: highpc.c,v 1.2 2000-05-23 20:40:36 jeroen 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 | #include "glheader.h"
|
|---|
| 28 | #include "types.h" /* for MESA_VERBOSE */
|
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 | /*
|
|---|
| 32 | * This is the highest address in Mesa
|
|---|
| 33 | */
|
|---|
| 34 | void mesa_highpc(void) { }
|
|---|
| 35 |
|
|---|
| 36 | #if defined(__GNUC__) && defined(__linux__)
|
|---|
| 37 |
|
|---|
| 38 | void monstartup( char *lowpc, char *highpc );
|
|---|
| 39 | void _mcleanup( void );
|
|---|
| 40 | void mesa_lowpc( void );
|
|---|
| 41 | void mesa_highpc( void );
|
|---|
| 42 |
|
|---|
| 43 | static int profile = 0;
|
|---|
| 44 |
|
|---|
| 45 | void force_init_prof( void )
|
|---|
| 46 | {
|
|---|
| 47 | FILE *fp;
|
|---|
| 48 |
|
|---|
| 49 | if (profile) return;
|
|---|
| 50 |
|
|---|
| 51 | profile = 1;
|
|---|
| 52 |
|
|---|
| 53 | monstartup( (char *)mesa_lowpc, (char *)mesa_highpc );
|
|---|
| 54 |
|
|---|
| 55 | fprintf(stderr, "Starting profiling, %x %x\n",
|
|---|
| 56 | (unsigned int)mesa_lowpc,
|
|---|
| 57 | (unsigned int)mesa_highpc);
|
|---|
| 58 |
|
|---|
| 59 | if ((fp = fopen( "mesa_lowpc", "w" )) != NULL) {
|
|---|
| 60 | fprintf( fp, "0x%08x ", (unsigned int)mesa_lowpc );
|
|---|
| 61 | fclose( fp );
|
|---|
| 62 | }
|
|---|
| 63 | }
|
|---|
| 64 |
|
|---|
| 65 | /*
|
|---|
| 66 | * Start profiling
|
|---|
| 67 | */
|
|---|
| 68 | void __attribute__ ((constructor))
|
|---|
| 69 | init_prof( void )
|
|---|
| 70 | {
|
|---|
| 71 | FILE *fp;
|
|---|
| 72 | char *s = getenv("MESA_MON");
|
|---|
| 73 |
|
|---|
| 74 | if (s == NULL || atoi(s) == 0)
|
|---|
| 75 | return;
|
|---|
| 76 |
|
|---|
| 77 | profile = 1;
|
|---|
| 78 |
|
|---|
| 79 | monstartup( (char *)mesa_lowpc, (char *)mesa_highpc );
|
|---|
| 80 |
|
|---|
| 81 | fprintf(stderr, "Starting profiling, %x %x\n",
|
|---|
| 82 | (unsigned int)mesa_lowpc,
|
|---|
| 83 | (unsigned int)mesa_highpc);
|
|---|
| 84 |
|
|---|
| 85 | if ((fp = fopen( "mesa_lowpc", "w" )) != NULL) {
|
|---|
| 86 | fprintf( fp, "0x%08x ", (unsigned int)mesa_lowpc );
|
|---|
| 87 | fclose( fp );
|
|---|
| 88 | }
|
|---|
| 89 | }
|
|---|
| 90 |
|
|---|
| 91 |
|
|---|
| 92 |
|
|---|
| 93 | /*
|
|---|
| 94 | * Finish profiling
|
|---|
| 95 | */
|
|---|
| 96 | void __attribute__ ((destructor))
|
|---|
| 97 | fini_prof( void )
|
|---|
| 98 | {
|
|---|
| 99 | if (profile) {
|
|---|
| 100 | _mcleanup( );
|
|---|
| 101 |
|
|---|
| 102 | fprintf(stderr, "Finished profiling\n");
|
|---|
| 103 | }
|
|---|
| 104 | }
|
|---|
| 105 |
|
|---|
| 106 | #else
|
|---|
| 107 |
|
|---|
| 108 | void force_init_prof( void )
|
|---|
| 109 | {
|
|---|
| 110 | }
|
|---|
| 111 |
|
|---|
| 112 | #endif
|
|---|