changeset 30:48369c6aeaa0 compile-milestone

brought prof package in
author Robert McIntyre <rlm@mit.edu>
date Sun, 04 Mar 2012 22:32:01 -0600
parents 2fa26addb901
children 094360cdf3b2
files configure.ac src/Makefile.am src/Port.h src/prof/Makefile src/prof/Makefile.am src/prof/gmon.h src/prof/gmon_out.h src/prof/prof.cpp src/prof/prof.h src/sdl/Makefile.am src/sdl/SDL.cpp
diffstat 11 files changed, 1150 insertions(+), 79 deletions(-) [+]
line wrap: on
line diff
     1.1 --- a/configure.ac	Sun Mar 04 21:09:22 2012 -0600
     1.2 +++ b/configure.ac	Sun Mar 04 22:32:01 2012 -0600
     1.3 @@ -21,7 +21,16 @@
     1.4  AC_PATH_PROG(NASM, nasm)
     1.5  
     1.6  # Checks for libraries.
     1.7 +AC_CHECK_LIB(z, gzopen,
     1.8 +  , AC_MSG_ERROR([*** Cannot compile without zlib.]))
     1.9 +AC_CHECK_LIB(png, png_create_write_struct,
    1.10 +  , AC_MSG_ERROR([*** Cannot compile without libpng.]), [-lz])
    1.11 +
    1.12 +SDL_VERSION=1.2.2
    1.13 +AM_PATH_SDL($SDL_VERSION, :,
    1.14 +            AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!]))
    1.15  AC_CHECK_LIB([SDL], [SDL_Init])
    1.16 +
    1.17  AC_CHECK_LIB([pthread], [pthread_create])
    1.18  
    1.19  
    1.20 @@ -61,9 +70,14 @@
    1.21  		 src/common/Makefile
    1.22  		 src/SFMT/Makefile
    1.23  		 src/filters/Makefile
    1.24 +		 src/prof/Makefile
    1.25  		 src/sdl/Makefile])
    1.26  
    1.27  
    1.28  
    1.29 +### RLM: investigate this further
    1.30 +CXXFLAGS="$CXXFLAGS -DC_CORE"	
    1.31 +
    1.32 +
    1.33  AC_OUTPUT
    1.34  
     2.1 --- a/src/Makefile.am	Sun Mar 04 21:09:22 2012 -0600
     2.2 +++ b/src/Makefile.am	Sun Mar 04 22:32:01 2012 -0600
     2.3 @@ -1,3 +1,3 @@
     2.4 -SUBDIRS = SFMT lua gb gba common filters sdl
     2.5 +SUBDIRS = SFMT lua gb gba common filters prof sdl
     2.6  
     2.7 -noinst_HEADERS = Port.h NLS.h AutoBuild.h
     2.8 +noinst_HEADERS = Port.h NLS.h AutoBuild.h version.h
     3.1 --- a/src/Port.h	Sun Mar 04 21:09:22 2012 -0600
     3.2 +++ b/src/Port.h	Sun Mar 04 22:32:01 2012 -0600
     3.3 @@ -13,9 +13,22 @@
     3.4  
     3.5  typedef unsigned char bool8;
     3.6  
     3.7 -#ifdef HAVE_STDINT_H
     3.8 +//#ifdef HAVE_STDINT_H
     3.9  #include <stdint.h>
    3.10  
    3.11 +// RLM combatibility junk
    3.12 +
    3.13 +typedef uint8_t u8;
    3.14 +typedef uint16_t u16;
    3.15 +typedef uint32_t u32;
    3.16 +typedef uint64_t u64;
    3.17 +
    3.18 +typedef int8_t s8;
    3.19 +typedef int16_t s16;
    3.20 +typedef int32_t s32;
    3.21 +typedef int64_t s64;
    3.22 +
    3.23 +
    3.24  typedef int8_t   int8;
    3.25  typedef uint8_t  uint8;
    3.26  typedef int16_t  int16;
    3.27 @@ -26,55 +39,6 @@
    3.28  typedef uint64_t uint64;
    3.29  typedef intptr_t pint;
    3.30  
    3.31 -#else /* Don't have stdint.h */
    3.32 -
    3.33 -#ifdef PTR_NOT_INT
    3.34 -typedef long pint;
    3.35 -#else /* pointer is int */
    3.36 -typedef int pint;
    3.37 -#endif /* PTR_NOT_INT */
    3.38 -
    3.39 -/* FIXME: Refactor this by moving out the BORLAND part and unifying typedefs */
    3.40 -#ifndef WIN32
    3.41 -typedef unsigned char  uint8;
    3.42 -typedef unsigned short uint16;
    3.43 -typedef signed char    int8;
    3.44 -typedef short          int16;
    3.45 -typedef int            int32;
    3.46 -typedef unsigned int   uint32;
    3.47 -# ifdef __GNUC__  /* long long is not part of ISO C++ */
    3.48 -__extension__ typedef long long          int64;
    3.49 -__extension__ typedef unsigned long long uint64;
    3.50 -# else
    3.51 -typedef long long          int64;
    3.52 -typedef unsigned long long uint64;
    3.53 -# endif
    3.54 -#else /* WIN32 */
    3.55 -
    3.56 -# ifdef __BORLANDC__
    3.57 -#   include <systypes.h>
    3.58 -# else
    3.59 -
    3.60 -typedef unsigned char  uint8;
    3.61 -typedef unsigned short uint16;
    3.62 -typedef signed char    int8;
    3.63 -typedef short          int16;
    3.64 -
    3.65 -# ifndef WSAAPI
    3.66 -/* winsock2.h typedefs int32 as well. */
    3.67 -typedef long int32;
    3.68 -# endif
    3.69 -
    3.70 -typedef unsigned int uint32;
    3.71 -
    3.72 -# endif /* __BORLANDC__ */
    3.73 -
    3.74 -typedef __int64          int64;
    3.75 -typedef unsigned __int64 uint64;
    3.76 -
    3.77 -#endif /* WIN32 */
    3.78 -#endif /* HAVE_STDINT_H */
    3.79 -
    3.80  #ifndef WIN32
    3.81  
    3.82  #ifndef PATH_MAX
    3.83 @@ -98,14 +62,6 @@
    3.84  #define strncasecmp strnicmp
    3.85  #endif
    3.86  
    3.87 -typedef uint8  u8;
    3.88 -typedef uint16 u16;
    3.89 -typedef uint32 u32;
    3.90 -typedef uint64 u64;
    3.91 -typedef int8   s8;
    3.92 -typedef int16  s16;
    3.93 -typedef int32  s32;
    3.94 -typedef int64  s64;
    3.95  
    3.96  // for consistency
    3.97  static inline u8 swap8(u8 v)
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/src/prof/Makefile	Sun Mar 04 22:32:01 2012 -0600
     4.3 @@ -0,0 +1,450 @@
     4.4 +# Makefile.in generated by automake 1.10.1 from Makefile.am.
     4.5 +# src/prof/Makefile.  Generated from Makefile.in by configure.
     4.6 +
     4.7 +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
     4.8 +# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
     4.9 +# This Makefile.in is free software; the Free Software Foundation
    4.10 +# gives unlimited permission to copy and/or distribute it,
    4.11 +# with or without modifications, as long as this notice is preserved.
    4.12 +
    4.13 +# This program is distributed in the hope that it will be useful,
    4.14 +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
    4.15 +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
    4.16 +# PARTICULAR PURPOSE.
    4.17 +
    4.18 +
    4.19 +
    4.20 +
    4.21 +pkgdatadir = $(datadir)/VisualBoyAdvance
    4.22 +pkglibdir = $(libdir)/VisualBoyAdvance
    4.23 +pkgincludedir = $(includedir)/VisualBoyAdvance
    4.24 +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
    4.25 +install_sh_DATA = $(install_sh) -c -m 644
    4.26 +install_sh_PROGRAM = $(install_sh) -c
    4.27 +install_sh_SCRIPT = $(install_sh) -c
    4.28 +INSTALL_HEADER = $(INSTALL_DATA)
    4.29 +transform = $(program_transform_name)
    4.30 +NORMAL_INSTALL = :
    4.31 +PRE_INSTALL = :
    4.32 +POST_INSTALL = :
    4.33 +NORMAL_UNINSTALL = :
    4.34 +PRE_UNINSTALL = :
    4.35 +POST_UNINSTALL = :
    4.36 +build_triplet = x86_64-unknown-linux-gnu
    4.37 +host_triplet = x86_64-unknown-linux-gnu
    4.38 +target_triplet = x86_64-unknown-linux-gnu
    4.39 +subdir = src/prof
    4.40 +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
    4.41 +OBJDIR = $(top_srcdir)/src/obj
    4.42 +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
    4.43 +am__aclocal_m4_deps = $(top_srcdir)/m4/gettext.m4 \
    4.44 +	$(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/lib-ld.m4 \
    4.45 +	$(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \
    4.46 +	$(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/po.m4 \
    4.47 +	$(top_srcdir)/m4/progtest.m4 $(top_srcdir)/acinclude.m4 \
    4.48 +	$(top_srcdir)/configure.in
    4.49 +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
    4.50 +	$(ACLOCAL_M4)
    4.51 +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
    4.52 +CONFIG_CLEAN_FILES =
    4.53 +LIBRARIES = $(noinst_LIBRARIES)
    4.54 +AR = ar
    4.55 +ARFLAGS = cru
    4.56 +libprof_a_AR = $(AR) $(ARFLAGS)
    4.57 +libprof_a_LIBADD =
    4.58 +am_libprof_a_OBJECTS = prof.$(OBJEXT)
    4.59 +libprof_a_OBJECTS = $(patsubst %,$(OBJDIR)/%,$(am_libprof_a_OBJECTS))
    4.60 +DEFAULT_INCLUDES = -I.
    4.61 +depcomp = $(SHELL) $(top_srcdir)/depcomp
    4.62 +am__depfiles_maybe = depfiles
    4.63 +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
    4.64 +	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
    4.65 +CXXLD = $(CXX)
    4.66 +CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \
    4.67 +	-o $@
    4.68 +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
    4.69 +	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
    4.70 +CCLD = $(CC)
    4.71 +LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
    4.72 +SOURCES = $(libprof_a_SOURCES)
    4.73 +DIST_SOURCES = $(libprof_a_SOURCES)
    4.74 +ETAGS = etags
    4.75 +CTAGS = ctags
    4.76 +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
    4.77 +ACLOCAL = ${SHELL} /home/r/proj/vba/trunk/missing --run aclocal-1.10
    4.78 +AMTAR = ${SHELL} /home/r/proj/vba/trunk/missing --run tar
    4.79 +AUTOCONF = ${SHELL} /home/r/proj/vba/trunk/missing --run autoconf
    4.80 +AUTOHEADER = ${SHELL} /home/r/proj/vba/trunk/missing --run autoheader
    4.81 +AUTOMAKE = ${SHELL} /home/r/proj/vba/trunk/missing --run automake-1.10
    4.82 +AWK = gawk
    4.83 +CC = gcc
    4.84 +CCDEPMODE = depmode=gcc3
    4.85 +CFLAGS = -g -O2
    4.86 +CPP = gcc -E
    4.87 +CPPFLAGS = 
    4.88 +CXX = g++
    4.89 +CXXDEPMODE = depmode=gcc3
    4.90 +CXXFLAGS = -g -O2 -DC_CORE -DDEV_VERSION
    4.91 +CYGPATH_W = echo
    4.92 +DEFS = -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DPACKAGE=\"VisualBoyAdvance\" -DVERSION=\"1.7.2\" -DYYTEXT_POINTER=1 -DHAVE_LIBZ=1 -DHAVE_LIBPNG=1 -DHAVE_LIBPTHREAD=1 -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_MALLOC_H=1 -DHAVE_STRINGS_H=1 -DHAVE_UNISTD_H=1 -DHAVE_ARPA_INET_H=1 -DHAVE_NETINET_IN_H=1
    4.93 +DEPDIR = .deps
    4.94 +ECHO_C = 
    4.95 +ECHO_N = -n
    4.96 +ECHO_T = 
    4.97 +EGREP = /bin/grep -E
    4.98 +EXEEXT = 
    4.99 +GETTEXT_PACKAGE = 
   4.100 +GMSGFMT = 
   4.101 +GREP = /bin/grep
   4.102 +GTKMM_CFLAGS = 
   4.103 +GTKMM_CPPFLAGS = 
   4.104 +GTKMM_LIBS = 
   4.105 +INSTALL = /usr/bin/install -c
   4.106 +INSTALL_DATA = ${INSTALL} -m 644
   4.107 +INSTALL_PROGRAM = ${INSTALL}
   4.108 +INSTALL_SCRIPT = ${INSTALL}
   4.109 +INSTALL_STRIP_PROGRAM = $(install_sh) -c -s
   4.110 +INTLLIBS = 
   4.111 +LDFLAGS = 
   4.112 +LEX = flex
   4.113 +LEXLIB = -lfl
   4.114 +LEX_OUTPUT_ROOT = lex.yy
   4.115 +LIBICONV = 
   4.116 +LIBINTL = 
   4.117 +LIBOBJS = 
   4.118 +LIBS = -lpthread -lpng -lz 
   4.119 +LTLIBICONV = 
   4.120 +LTLIBINTL = 
   4.121 +LTLIBOBJS = 
   4.122 +MAKEINFO = ${SHELL} /home/r/proj/vba/trunk/missing --run makeinfo
   4.123 +MKDIR_P = /bin/mkdir -p
   4.124 +MKINSTALLDIRS = 
   4.125 +MSGFMT = 
   4.126 +MSGMERGE = 
   4.127 +NASM = /usr/bin/nasm
   4.128 +OBJEXT = o
   4.129 +PACKAGE = VisualBoyAdvance
   4.130 +PACKAGE_BUGREPORT = 
   4.131 +PACKAGE_NAME = 
   4.132 +PACKAGE_STRING = 
   4.133 +PACKAGE_TARNAME = 
   4.134 +PACKAGE_VERSION = 
   4.135 +PATH_SEPARATOR = :
   4.136 +PKG_CONFIG = 
   4.137 +POSUB = 
   4.138 +RANLIB = ranlib
   4.139 +SDL_CFLAGS = -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT
   4.140 +SDL_CONFIG = /usr/bin/sdl-config
   4.141 +SDL_LIBS = -L/usr/lib -Wl,-rpath,/usr/lib -lSDL -lpthread
   4.142 +SET_MAKE = 
   4.143 +SHELL = /bin/sh
   4.144 +STRIP = 
   4.145 +USE_NLS = 
   4.146 +VBA_EXTRA = 
   4.147 +VBA_LIBS = ../gba/libgba.a ../gb/libgb.a ../common/libgbcom.a ../filters/libfilter.a ../lua/libgblua.a
   4.148 +VBA_SRC_EXTRA =  lua sdl
   4.149 +VERSION = 1.7.2
   4.150 +XGETTEXT = 
   4.151 +XMKMF = 
   4.152 +YACC = bison -y
   4.153 +YFLAGS = 
   4.154 +abs_builddir = /home/r/proj/vba/trunk/src/prof
   4.155 +abs_srcdir = /home/r/proj/vba/trunk/src/prof
   4.156 +abs_top_builddir = /home/r/proj/vba/trunk
   4.157 +abs_top_srcdir = /home/r/proj/vba/trunk
   4.158 +ac_ct_CC = gcc
   4.159 +ac_ct_CXX = g++
   4.160 +am__include = include
   4.161 +am__leading_dot = .
   4.162 +am__quote = 
   4.163 +am__tar = ${AMTAR} chof - "$$tardir"
   4.164 +am__untar = ${AMTAR} xf -
   4.165 +bindir = ${exec_prefix}/bin
   4.166 +build = x86_64-unknown-linux-gnu
   4.167 +build_alias = 
   4.168 +build_cpu = x86_64
   4.169 +build_os = linux-gnu
   4.170 +build_vendor = unknown
   4.171 +builddir = .
   4.172 +datadir = ${datarootdir}
   4.173 +datarootdir = ${prefix}/share
   4.174 +docdir = ${datarootdir}/doc/${PACKAGE}
   4.175 +dvidir = ${docdir}
   4.176 +exec_prefix = ${prefix}
   4.177 +host = x86_64-unknown-linux-gnu
   4.178 +host_alias = 
   4.179 +host_cpu = x86_64
   4.180 +host_os = linux-gnu
   4.181 +host_vendor = unknown
   4.182 +htmldir = ${docdir}
   4.183 +includedir = ${prefix}/include
   4.184 +infodir = ${datarootdir}/info
   4.185 +install_sh = $(SHELL) /home/r/proj/vba/trunk/install-sh
   4.186 +libdir = ${exec_prefix}/lib
   4.187 +libexecdir = ${exec_prefix}/libexec
   4.188 +localedir = ${datarootdir}/locale
   4.189 +localstatedir = ${prefix}/var
   4.190 +mandir = ${datarootdir}/man
   4.191 +mkdir_p = /bin/mkdir -p
   4.192 +oldincludedir = /usr/include
   4.193 +pdfdir = ${docdir}
   4.194 +prefix = /usr/local
   4.195 +program_transform_name = s,x,x,
   4.196 +psdir = ${docdir}
   4.197 +sbindir = ${exec_prefix}/sbin
   4.198 +sharedstatedir = ${prefix}/com
   4.199 +srcdir = .
   4.200 +sysconfdir = ${prefix}/etc
   4.201 +target = x86_64-unknown-linux-gnu
   4.202 +target_alias = 
   4.203 +target_cpu = x86_64
   4.204 +target_os = linux-gnu
   4.205 +target_vendor = unknown
   4.206 +top_builddir = ../..
   4.207 +top_srcdir = ../..
   4.208 +noinst_LIBRARIES = libprof.a
   4.209 +libprof_a_SOURCES = \
   4.210 +	gmon.h		\
   4.211 +	gmon_out.h	\
   4.212 +	prof.cpp	\
   4.213 +	prof.h
   4.214 +
   4.215 +all: all-am
   4.216 +
   4.217 +.SUFFIXES:
   4.218 +.SUFFIXES: .cpp .o .obj
   4.219 +$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
   4.220 +	@for dep in $?; do \
   4.221 +	  case '$(am__configure_deps)' in \
   4.222 +	    *$$dep*) \
   4.223 +	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
   4.224 +		&& exit 0; \
   4.225 +	      exit 1;; \
   4.226 +	  esac; \
   4.227 +	done; \
   4.228 +	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/prof/Makefile'; \
   4.229 +	cd $(top_srcdir) && \
   4.230 +	  $(AUTOMAKE) --gnu  src/prof/Makefile
   4.231 +.PRECIOUS: Makefile
   4.232 +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
   4.233 +	@case '$?' in \
   4.234 +	  *config.status*) \
   4.235 +	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
   4.236 +	  *) \
   4.237 +	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
   4.238 +	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
   4.239 +	esac;
   4.240 +
   4.241 +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
   4.242 +	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
   4.243 +
   4.244 +$(top_srcdir)/configure:  $(am__configure_deps)
   4.245 +	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
   4.246 +$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
   4.247 +	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
   4.248 +
   4.249 +clean-noinstLIBRARIES:
   4.250 +	-test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
   4.251 +libprof.a: $(libprof_a_OBJECTS) $(libprof_a_DEPENDENCIES) 
   4.252 +	-rm -f libprof.a
   4.253 +	$(libprof_a_AR) libprof.a $(libprof_a_OBJECTS) $(libprof_a_LIBADD)
   4.254 +	$(RANLIB) libprof.a
   4.255 +
   4.256 +mostlyclean-compile:
   4.257 +	-rm -f *.$(OBJEXT)
   4.258 +
   4.259 +distclean-compile:
   4.260 +	-rm -f *.tab.c
   4.261 +
   4.262 +include ./$(DEPDIR)/prof.Po
   4.263 +
   4.264 +$(OBJDIR)/%.o: %.cpp
   4.265 +	$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
   4.266 +	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
   4.267 +#	source='$<' object='$@' libtool=no \
   4.268 +#	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \
   4.269 +#	$(CXXCOMPILE) -c -o $@ $<
   4.270 +
   4.271 +.cpp.obj:
   4.272 +	$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
   4.273 +	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
   4.274 +#	source='$<' object='$@' libtool=no \
   4.275 +#	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \
   4.276 +#	$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
   4.277 +
   4.278 +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
   4.279 +	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
   4.280 +	unique=`for i in $$list; do \
   4.281 +	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
   4.282 +	  done | \
   4.283 +	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
   4.284 +	      END { if (nonempty) { for (i in files) print i; }; }'`; \
   4.285 +	mkid -fID $$unique
   4.286 +tags: TAGS
   4.287 +
   4.288 +TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
   4.289 +		$(TAGS_FILES) $(LISP)
   4.290 +	tags=; \
   4.291 +	here=`pwd`; \
   4.292 +	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
   4.293 +	unique=`for i in $$list; do \
   4.294 +	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
   4.295 +	  done | \
   4.296 +	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
   4.297 +	      END { if (nonempty) { for (i in files) print i; }; }'`; \
   4.298 +	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
   4.299 +	  test -n "$$unique" || unique=$$empty_fix; \
   4.300 +	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
   4.301 +	    $$tags $$unique; \
   4.302 +	fi
   4.303 +ctags: CTAGS
   4.304 +CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
   4.305 +		$(TAGS_FILES) $(LISP)
   4.306 +	tags=; \
   4.307 +	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
   4.308 +	unique=`for i in $$list; do \
   4.309 +	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
   4.310 +	  done | \
   4.311 +	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
   4.312 +	      END { if (nonempty) { for (i in files) print i; }; }'`; \
   4.313 +	test -z "$(CTAGS_ARGS)$$tags$$unique" \
   4.314 +	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
   4.315 +	     $$tags $$unique
   4.316 +
   4.317 +GTAGS:
   4.318 +	here=`$(am__cd) $(top_builddir) && pwd` \
   4.319 +	  && cd $(top_srcdir) \
   4.320 +	  && gtags -i $(GTAGS_ARGS) $$here
   4.321 +
   4.322 +distclean-tags:
   4.323 +	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
   4.324 +
   4.325 +distdir: $(DISTFILES)
   4.326 +	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
   4.327 +	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
   4.328 +	list='$(DISTFILES)'; \
   4.329 +	  dist_files=`for file in $$list; do echo $$file; done | \
   4.330 +	  sed -e "s|^$$srcdirstrip/||;t" \
   4.331 +	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
   4.332 +	case $$dist_files in \
   4.333 +	  */*) $(MKDIR_P) `echo "$$dist_files" | \
   4.334 +			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
   4.335 +			   sort -u` ;; \
   4.336 +	esac; \
   4.337 +	for file in $$dist_files; do \
   4.338 +	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
   4.339 +	  if test -d $$d/$$file; then \
   4.340 +	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
   4.341 +	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
   4.342 +	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
   4.343 +	    fi; \
   4.344 +	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
   4.345 +	  else \
   4.346 +	    test -f $(distdir)/$$file \
   4.347 +	    || cp -p $$d/$$file $(distdir)/$$file \
   4.348 +	    || exit 1; \
   4.349 +	  fi; \
   4.350 +	done
   4.351 +check-am: all-am
   4.352 +check: check-am
   4.353 +all-am: Makefile $(libprof_a_OBJECTS)
   4.354 +installdirs:
   4.355 +install: install-am
   4.356 +install-exec: install-exec-am
   4.357 +install-data: install-data-am
   4.358 +uninstall: uninstall-am
   4.359 +
   4.360 +install-am: all-am
   4.361 +	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
   4.362 +
   4.363 +installcheck: installcheck-am
   4.364 +install-strip:
   4.365 +	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
   4.366 +	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
   4.367 +	  `test -z '$(STRIP)' || \
   4.368 +	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
   4.369 +mostlyclean-generic:
   4.370 +
   4.371 +clean-generic:
   4.372 +
   4.373 +distclean-generic:
   4.374 +	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
   4.375 +
   4.376 +maintainer-clean-generic:
   4.377 +	@echo "This command is intended for maintainers to use"
   4.378 +	@echo "it deletes files that may require special tools to rebuild."
   4.379 +clean: clean-am
   4.380 +
   4.381 +clean-am: clean-generic clean-noinstLIBRARIES mostlyclean-am
   4.382 +
   4.383 +distclean: distclean-am
   4.384 +	-rm -rf ./$(DEPDIR)
   4.385 +	-rm -f Makefile
   4.386 +distclean-am: clean-am distclean-compile distclean-generic \
   4.387 +	distclean-tags
   4.388 +
   4.389 +dvi: dvi-am
   4.390 +
   4.391 +dvi-am:
   4.392 +
   4.393 +html: html-am
   4.394 +
   4.395 +info: info-am
   4.396 +
   4.397 +info-am:
   4.398 +
   4.399 +install-data-am:
   4.400 +
   4.401 +install-dvi: install-dvi-am
   4.402 +
   4.403 +install-exec-am:
   4.404 +
   4.405 +install-html: install-html-am
   4.406 +
   4.407 +install-info: install-info-am
   4.408 +
   4.409 +install-man:
   4.410 +
   4.411 +install-pdf: install-pdf-am
   4.412 +
   4.413 +install-ps: install-ps-am
   4.414 +
   4.415 +installcheck-am:
   4.416 +
   4.417 +maintainer-clean: maintainer-clean-am
   4.418 +	-rm -rf ./$(DEPDIR)
   4.419 +	-rm -f Makefile
   4.420 +maintainer-clean-am: distclean-am maintainer-clean-generic
   4.421 +
   4.422 +mostlyclean: mostlyclean-am
   4.423 +
   4.424 +mostlyclean-am: mostlyclean-compile mostlyclean-generic
   4.425 +
   4.426 +pdf: pdf-am
   4.427 +
   4.428 +pdf-am:
   4.429 +
   4.430 +ps: ps-am
   4.431 +
   4.432 +ps-am:
   4.433 +
   4.434 +uninstall-am:
   4.435 +
   4.436 +.MAKE: install-am install-strip
   4.437 +
   4.438 +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
   4.439 +	clean-noinstLIBRARIES ctags distclean distclean-compile \
   4.440 +	distclean-generic distclean-tags distdir dvi dvi-am html \
   4.441 +	html-am info info-am install install-am install-data \
   4.442 +	install-data-am install-dvi install-dvi-am install-exec \
   4.443 +	install-exec-am install-html install-html-am install-info \
   4.444 +	install-info-am install-man install-pdf install-pdf-am \
   4.445 +	install-ps install-ps-am install-strip installcheck \
   4.446 +	installcheck-am installdirs maintainer-clean \
   4.447 +	maintainer-clean-generic mostlyclean mostlyclean-compile \
   4.448 +	mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \
   4.449 +	uninstall-am
   4.450 +
   4.451 +# Tell versions [3.59,3.63) of GNU make to not export all variables.
   4.452 +# Otherwise a system limit (for SysV at least) may be exceeded.
   4.453 +.NOEXPORT:
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/src/prof/Makefile.am	Sun Mar 04 22:32:01 2012 -0600
     5.3 @@ -0,0 +1,7 @@
     5.4 +noinst_LIBRARIES = libprof.a
     5.5 +
     5.6 +libprof_a_SOURCES = \
     5.7 +	gmon.h		\
     5.8 +	gmon_out.h	\
     5.9 +	prof.cpp	\
    5.10 +	prof.h
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/src/prof/gmon.h	Sun Mar 04 22:32:01 2012 -0600
     6.3 @@ -0,0 +1,151 @@
     6.4 +/*
     6.5 + * Copyright (c) 1983, 1991, 1993, 2001
     6.6 + *      The Regents of the University of California.  All rights reserved.
     6.7 + *
     6.8 + * Redistribution and use in source and binary forms, with or without
     6.9 + * modification, are permitted provided that the following conditions
    6.10 + * are met:
    6.11 + * 1. Redistributions of source code must retain the above copyright
    6.12 + *    notice, this list of conditions and the following disclaimer.
    6.13 + * 2. Redistributions in binary form must reproduce the above copyright
    6.14 + *    notice, this list of conditions and the following disclaimer in the
    6.15 + *    documentation and/or other materials provided with the distribution.
    6.16 + * 3. Neither the name of the University nor the names of its contributors
    6.17 + *    may be used to endorse or promote products derived from this software
    6.18 + *    without specific prior written permission.
    6.19 + *
    6.20 + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
    6.21 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    6.22 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    6.23 + * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
    6.24 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
    6.25 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
    6.26 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    6.27 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
    6.28 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
    6.29 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    6.30 + * SUCH DAMAGE.
    6.31 + */
    6.32 +#ifndef gmon_h
    6.33 +#define gmon_h
    6.34 +
    6.35 +#include <stdint.h>
    6.36 +typedef uint32_t u32;
    6.37 +
    6.38 +/* Size of the 4.4BSD gmon header */
    6.39 +#define GMON_HDRSIZE_BSD44_32 (4 + 4 + 4 + 4 + 4 + (3 * 4))
    6.40 +#define GMON_HDRSIZE_BSD44_64 (8 + 8 + 4 + 4 + 4 + (3 * 4))
    6.41 +
    6.42 +#if 0 /* For documentation purposes only.  */
    6.43 +  struct raw_phdr
    6.44 +    {
    6.45 +      char low_pc[sizeof(void *)]; /* base pc address of sample buffer */
    6.46 +      char high_pc[sizeof(void *)];/* max pc address of sampled buffer */
    6.47 +      char ncnt[4];		   /* size of sample buffer (plus this
    6.48 +				      header) */
    6.49 +
    6.50 +      char version[4];		   /* version number */
    6.51 +      char profrate[4];		   /* profiling clock rate */
    6.52 +      char spare[3*4];		   /* reserved */
    6.53 +    };
    6.54 +#endif
    6.55 +
    6.56 +#define GMONVERSION     0x00051879
    6.57 +
    6.58 +/* Size of the old BSD gmon header */
    6.59 +#define GMON_HDRSIZE_OLDBSD_32 (4 + 4 + 4) 
    6.60 +
    6.61 +/* FIXME: Checking host compiler defines here means that we can't
    6.62 +   use a cross gprof alpha OSF.  */
    6.63 +#if defined(__alpha__) && defined (__osf__) 
    6.64 +#define GMON_HDRSIZE_OLDBSD_64 (8 + 8 + 4 + 4)
    6.65 +#else
    6.66 +#define GMON_HDRSIZE_OLDBSD_64 (8 + 8 + 4)
    6.67 +#endif
    6.68 +
    6.69 +#if 0 /* For documentation purposes only.  */
    6.70 +  struct old_raw_phdr
    6.71 +    {
    6.72 +      char low_pc[sizeof(void *)]; /* base pc address of sample buffer */
    6.73 +      char high_pc[sizeof(void *)];/* max pc address of sampled buffer */
    6.74 +      char ncnt[4];		   /* size of sample buffer (plus this
    6.75 +				      header) */
    6.76 +#if defined (__alpha__) && defined (__osf__)
    6.77 +      /*
    6.78 +       * DEC's OSF v3.0 uses 4 bytes of padding to bring the header to
    6.79 +       * a size that is a multiple of 8.
    6.80 +       */
    6.81 +      char pad[4];
    6.82 +#endif
    6.83 +    };
    6.84 +#endif
    6.85 +
    6.86 +/*
    6.87 + * Histogram counters are unsigned shorts:
    6.88 + */
    6.89 +#define	HISTCOUNTER unsigned short
    6.90 +
    6.91 +/*
    6.92 + * Fraction of text space to allocate for histogram counters here, 1/2:
    6.93 + */
    6.94 +#define	HISTFRACTION	2
    6.95 +
    6.96 +/*
    6.97 + * Fraction of text space to allocate for from hash buckets.  The
    6.98 + * value of HASHFRACTION is based on the minimum number of bytes of
    6.99 + * separation between two subroutine call points in the object code.
   6.100 + * Given MIN_SUBR_SEPARATION bytes of separation the value of
   6.101 + * HASHFRACTION is calculated as:
   6.102 + *
   6.103 + *      HASHFRACTION = MIN_SUBR_SEPARATION / (2 * sizeof(short) - 1);
   6.104 + *
   6.105 + * For the VAX, the shortest two call sequence is:
   6.106 + *
   6.107 + *      calls   $0,(r0)
   6.108 + *      calls   $0,(r0)
   6.109 + *
   6.110 + * which is separated by only three bytes, thus HASHFRACTION is
   6.111 + * calculated as:
   6.112 + *
   6.113 + *      HASHFRACTION = 3 / (2 * 2 - 1) = 1
   6.114 + *
   6.115 + * Note that the division above rounds down, thus if MIN_SUBR_FRACTION
   6.116 + * is less than three, this algorithm will not work!
   6.117 + */
   6.118 +#define	HASHFRACTION 1
   6.119 +
   6.120 +/*
   6.121 + * Percent of text space to allocate for tostructs with a minimum:
   6.122 + */
   6.123 +#define ARCDENSITY	2
   6.124 +#define MINARCS		50
   6.125 +
   6.126 +struct tostruct
   6.127 +  {
   6.128 +    u32 selfpc;
   6.129 +    int count;
   6.130 +    unsigned short link;
   6.131 +  };
   6.132 +
   6.133 +/*
   6.134 + * A raw arc, with pointers to the calling site and the called site
   6.135 + * and a count.  Everything is defined in terms of characters so
   6.136 + * as to get a packed representation (otherwise, different compilers
   6.137 + * might introduce different padding):
   6.138 + */
   6.139 +#if 0 /* For documentation purposes only.  */
   6.140 +  struct raw_arc
   6.141 +    {
   6.142 +      char from_pc[sizeof(void *)];
   6.143 +      char self_pc[sizeof(void *)];
   6.144 +      char count[sizeof(long)];
   6.145 +    };
   6.146 +#endif
   6.147 +
   6.148 +/*
   6.149 + * General rounding functions:
   6.150 + */
   6.151 +#define ROUNDDOWN(x,y)	(((x)/(y))*(y))
   6.152 +#define ROUNDUP(x,y)	((((x)+(y)-1)/(y))*(y))
   6.153 +
   6.154 +#endif /* gmon_h */
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/src/prof/gmon_out.h	Sun Mar 04 22:32:01 2012 -0600
     7.3 @@ -0,0 +1,45 @@
     7.4 +/* gmon_out.h
     7.5 +
     7.6 +   Copyright 2000, 2001 Free Software Foundation, Inc.
     7.7 +
     7.8 +This file is part of GNU Binutils.
     7.9 +
    7.10 +This program is free software; you can redistribute it and/or modify
    7.11 +it under the terms of the GNU General Public License as published by
    7.12 +the Free Software Foundation; either version 2 of the License, or
    7.13 +(at your option) any later version.
    7.14 +
    7.15 +This program is distributed in the hope that it will be useful,
    7.16 +but WITHOUT ANY WARRANTY; without even the implied warranty of
    7.17 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    7.18 +GNU General Public License for more details.
    7.19 +
    7.20 +You should have received a copy of the GNU General Public License
    7.21 +along with this program; if not, write to the Free Software
    7.22 +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
    7.23 +
    7.24 +/* A gmon.out file consists of a header (defined by gmon_hdr) followed
    7.25 +   by a sequence of records.  Each record starts with a one-byte tag
    7.26 +   identifying the type of records, followed by records specific data.  */
    7.27 +#ifndef gmon_out_h
    7.28 +#define gmon_out_h
    7.29 +
    7.30 +#define	GMON_MAGIC	"gmon"	/* magic cookie */
    7.31 +#define GMON_VERSION	1	/* version number */
    7.32 +
    7.33 +/* Raw header as it appears on file (without padding).  */
    7.34 +struct gmon_hdr
    7.35 +  {
    7.36 +    char cookie[4];
    7.37 +    char version[4];
    7.38 +    char spare[3 * 4];
    7.39 +  };
    7.40 +
    7.41 +/* Types of records in this file.  */
    7.42 +typedef enum
    7.43 +  {
    7.44 +    GMON_TAG_TIME_HIST = 0, GMON_TAG_CG_ARC = 1, GMON_TAG_BB_COUNT = 2
    7.45 +  }
    7.46 +GMON_Record_Tag;
    7.47 +
    7.48 +#endif /* gmon_out_h */
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/src/prof/prof.cpp	Sun Mar 04 22:32:01 2012 -0600
     8.3 @@ -0,0 +1,405 @@
     8.4 +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
     8.5 +// Copyright (C) 1999-2003 Forgotten
     8.6 +// Copyright (C) 2004 Forgotten and the VBA development team
     8.7 +
     8.8 +// This program is free software; you can redistribute it and/or modify
     8.9 +// it under the terms of the GNU General Public License as published by
    8.10 +// the Free Software Foundation; either version 2, or(at your option)
    8.11 +// any later version.
    8.12 +//
    8.13 +// This program is distributed in the hope that it will be useful,
    8.14 +// but WITHOUT ANY WARRANTY; without even the implied warranty of
    8.15 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    8.16 +// GNU General Public License for more details.
    8.17 +//
    8.18 +// You should have received a copy of the GNU General Public License
    8.19 +// along with this program; if not, write to the Free Software Foundation,
    8.20 +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
    8.21 +
    8.22 +// adapted from gmon.c
    8.23 +/*-
    8.24 + * Copyright (c) 1991, 1998 The Regents of the University of California.
    8.25 + * All rights reserved.
    8.26 + *
    8.27 + * Redistribution and use in source and binary forms, with or without
    8.28 + * modification, are permitted provided that the following conditions
    8.29 + * are met:
    8.30 + * 1. Redistributions of source code must retain the above copyright
    8.31 + *    notice, this list of conditions and the following disclaimer.
    8.32 + * 2. Redistributions in binary form must reproduce the above copyright
    8.33 + *    notice, this list of conditions and the following disclaimer in the
    8.34 + *    documentation and/or other materials provided with the distribution.
    8.35 + * 3. [rescinded 22 July 1999]
    8.36 + * 4. Neither the name of the University nor the names of its contributors
    8.37 + *    may be used to endorse or promote products derived from this software
    8.38 + *    without specific prior written permission.
    8.39 + *
    8.40 + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
    8.41 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    8.42 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    8.43 + * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
    8.44 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
    8.45 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
    8.46 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    8.47 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
    8.48 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
    8.49 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    8.50 + * SUCH DAMAGE.
    8.51 + */
    8.52 +
    8.53 +#include <stdlib.h>
    8.54 +#include <stdio.h>
    8.55 +#include <memory.h>
    8.56 +
    8.57 +#include "gmon.h"
    8.58 +#include "gmon_out.h"
    8.59 +
    8.60 +#include "../common/System.h"
    8.61 +#include "../gba/GBA.h"
    8.62 +#include "../gba/GBAGlobals.h"
    8.63 +#include "../NLS.h"
    8.64 +
    8.65 +/*
    8.66 + * froms is actually a bunch of unsigned shorts indexing tos
    8.67 + */
    8.68 +static int  profiling = 3;
    8.69 +static unsigned short *froms;
    8.70 +static struct tostruct *tos = 0;
    8.71 +static long  tolimit = 0;
    8.72 +static u32  s_lowpc = 0;
    8.73 +static u32  s_highpc = 0;
    8.74 +static unsigned long s_textsize = 0;
    8.75 +
    8.76 +static int ssiz;
    8.77 +static char *sbuf;
    8.78 +static int s_scale;
    8.79 +
    8.80 +static int hz = 0;
    8.81 +static int hist_num_bins = 0;
    8.82 +static char hist_dimension[16] = "seconds";
    8.83 +static char hist_dimension_abbrev = 's';
    8.84 +
    8.85 +/* see profil(2) where this is describe (incorrectly) */
    8.86 +#define  SCALE_1_TO_1 0x10000L
    8.87 +
    8.88 +void profPut32(char *b, u32 v)
    8.89 +{
    8.90 +  b[0] = v & 255;
    8.91 +  b[1] = (v >> 8) & 255;
    8.92 +  b[2] = (v >> 16) & 255;
    8.93 +  b[3] = (v >> 24) & 255;
    8.94 +}
    8.95 +
    8.96 +void profPut16(char *b, u16 v)
    8.97 +{
    8.98 +  b[0] = v & 255;
    8.99 +  b[1] = (v >> 8) & 255;
   8.100 +}
   8.101 +
   8.102 +int profWrite8(FILE *f, u8 b)
   8.103 +{
   8.104 +  if(fwrite(&b, 1, 1, f) != 1)
   8.105 +    return 1;
   8.106 +  return 0;
   8.107 +}
   8.108 +
   8.109 +int profWrite32(FILE *f, u32 v)
   8.110 +{
   8.111 +  char buf[4];
   8.112 +
   8.113 +  profPut32(buf, v);
   8.114 +  if(fwrite(buf, 1, 4, f) != 4)
   8.115 +    return 1;
   8.116 +  return 0;
   8.117 +}
   8.118 +
   8.119 +int profWrite(FILE *f, char *buf, unsigned int n)
   8.120 +{
   8.121 +  if(fwrite(buf, 1, n, f) != n)
   8.122 +    return 1;
   8.123 +  return 0;
   8.124 +}
   8.125 +
   8.126 +/* Control profiling;
   8.127 +   profiling is what mcount checks to see if
   8.128 +   all the data structures are ready.  */
   8.129 +
   8.130 +void profControl(int mode)
   8.131 +{
   8.132 +  if (mode) {
   8.133 +    /* start */
   8.134 +#ifdef PROFILING
   8.135 +    cpuProfil(sbuf, ssiz, (u32)s_lowpc, s_scale);
   8.136 +#endif
   8.137 +    profiling = 0;
   8.138 +  } else {
   8.139 +    /* stop */
   8.140 +#ifdef PROFILING
   8.141 +    cpuProfil(NULL, 0, 0, 0);
   8.142 +#endif
   8.143 +    profiling = 3;
   8.144 +  }
   8.145 +}
   8.146 +
   8.147 +
   8.148 +#define MSG N_("No space for profiling buffer(s)\n")
   8.149 +
   8.150 +void profStartup(u32 lowpc, u32 highpc)
   8.151 +{
   8.152 +  int monsize;
   8.153 +  char *buffer;
   8.154 +  int o;
   8.155 +  
   8.156 +  /*
   8.157 +   * round lowpc and highpc to multiples of the density we're using
   8.158 +   * so the rest of the scaling (here and in gprof) stays in ints.
   8.159 +   */
   8.160 +  lowpc = ROUNDDOWN(lowpc, HISTFRACTION*sizeof(HISTCOUNTER));
   8.161 +  s_lowpc = lowpc;
   8.162 +  highpc = ROUNDUP(highpc, HISTFRACTION*sizeof(HISTCOUNTER));
   8.163 +  s_highpc = highpc;
   8.164 +  s_textsize = highpc - lowpc;
   8.165 +  monsize = (s_textsize / HISTFRACTION);
   8.166 +  buffer = (char *)calloc(1, 2*monsize );
   8.167 +  if ( buffer == NULL ) {
   8.168 +    systemMessage(0, MSG);
   8.169 +    return;
   8.170 +  }
   8.171 +  froms = (unsigned short *) calloc(1, 4*s_textsize / HASHFRACTION );
   8.172 +  if ( froms == NULL ) {
   8.173 +    systemMessage(0, MSG);
   8.174 +    free(buffer);
   8.175 +    buffer = NULL;
   8.176 +    return;
   8.177 +  }
   8.178 +  tolimit = s_textsize * ARCDENSITY / 100;
   8.179 +  if ( tolimit < MINARCS ) {
   8.180 +    tolimit = MINARCS;
   8.181 +  } else if ( tolimit > 65534 ) {
   8.182 +    tolimit = 65534;
   8.183 +  }
   8.184 +  tos = (struct tostruct *) calloc(1, tolimit * sizeof( struct tostruct ) );
   8.185 +  if ( tos == NULL ) {
   8.186 +    systemMessage(0, MSG);
   8.187 +    
   8.188 +    free(buffer);
   8.189 +    buffer = NULL;
   8.190 +    
   8.191 +    free(froms);
   8.192 +    froms = NULL;
   8.193 +    
   8.194 +    return;
   8.195 +  }
   8.196 +  tos[0].link = 0;
   8.197 +  sbuf = buffer;
   8.198 +  ssiz = monsize;
   8.199 +  if ( monsize <= 0 )
   8.200 +    return;
   8.201 +  o = highpc - lowpc;
   8.202 +  if( monsize < o )
   8.203 +    s_scale = (int)(( (float) monsize / o ) * SCALE_1_TO_1);
   8.204 +  else
   8.205 +    s_scale = SCALE_1_TO_1;
   8.206 +  profControl(1);
   8.207 +}
   8.208 +
   8.209 +void profCleanup()
   8.210 +{
   8.211 +  FILE *fd;
   8.212 +  int fromindex;
   8.213 +  int endfrom;
   8.214 +  u32 frompc;
   8.215 +  int toindex;
   8.216 +  struct gmon_hdr ghdr;
   8.217 +  
   8.218 +  profControl(0);
   8.219 +  fd = fopen( "gmon.out" , "wb" );
   8.220 +  if ( fd == NULL ) {
   8.221 +    systemMessage( 0, "mcount: gmon.out" );
   8.222 +    return;
   8.223 +  }
   8.224 +
   8.225 +  memcpy(&ghdr.cookie[0], GMON_MAGIC, 4);
   8.226 +  profPut32((char *)ghdr.version, GMON_VERSION);
   8.227 +
   8.228 +  if(fwrite(&ghdr, sizeof(ghdr), 1, fd) != 1) {
   8.229 +    systemMessage(0, "mcount: gmon.out header");
   8.230 +    fclose(fd);
   8.231 +    return;
   8.232 +  }
   8.233 +
   8.234 +  if(hz == 0)
   8.235 +    hz = 100;
   8.236 +
   8.237 +  hist_num_bins = ssiz;
   8.238 +  
   8.239 +  if(profWrite8(fd, GMON_TAG_TIME_HIST) ||
   8.240 +     profWrite32(fd, (u32)s_lowpc) ||
   8.241 +     profWrite32(fd, (u32)s_highpc) ||
   8.242 +     profWrite32(fd, hist_num_bins) ||
   8.243 +     profWrite32(fd, hz) ||
   8.244 +     profWrite(fd, hist_dimension, 15) ||
   8.245 +     profWrite(fd, &hist_dimension_abbrev, 1)) {
   8.246 +    systemMessage(0, "mcount: gmon.out hist");
   8.247 +    fclose(fd);
   8.248 +    return;
   8.249 +  }
   8.250 +  u16 *hist_sample = (u16 *)sbuf;
   8.251 +
   8.252 +  u16 count;
   8.253 +  int i;
   8.254 +  
   8.255 +  for(i = 0; i < hist_num_bins; ++i) {
   8.256 +    profPut16((char *)&count, hist_sample[i]);
   8.257 +
   8.258 +    if(fwrite(&count, sizeof(count), 1, fd) != 1) {
   8.259 +      systemMessage(0, "mcount: gmon.out sample");
   8.260 +      fclose(fd);
   8.261 +      return;
   8.262 +    }
   8.263 +  }
   8.264 +  
   8.265 +  endfrom = s_textsize / (HASHFRACTION * sizeof(*froms));
   8.266 +  for ( fromindex = 0 ; fromindex < endfrom ; fromindex++ ) {
   8.267 +    if ( froms[fromindex] == 0 ) {
   8.268 +      continue;
   8.269 +    }
   8.270 +    frompc = s_lowpc + (fromindex * HASHFRACTION * sizeof(*froms));
   8.271 +    for (toindex=froms[fromindex]; toindex!=0; toindex=tos[toindex].link) {
   8.272 +      if(profWrite8(fd, GMON_TAG_CG_ARC) ||
   8.273 +         profWrite32(fd, (u32)frompc) ||
   8.274 +         profWrite32(fd, (u32)tos[toindex].selfpc) ||
   8.275 +         profWrite32(fd, tos[toindex].count)) {
   8.276 +        systemMessage(0, "mcount: arc");
   8.277 +        fclose(fd);
   8.278 +        return;
   8.279 +      }
   8.280 +    }
   8.281 +  }
   8.282 +  fclose(fd);
   8.283 +}
   8.284 +
   8.285 +void profCount()
   8.286 +{
   8.287 +  register u32 selfpc;
   8.288 +  register unsigned short *frompcindex;
   8.289 +  register struct tostruct *top;
   8.290 +  register struct tostruct *prevtop;
   8.291 +  register long toindex;
   8.292 +
   8.293 +  /*
   8.294 +   * find the return address for mcount,
   8.295 +   * and the return address for mcount's caller.
   8.296 +   */
   8.297 +  
   8.298 +  /* selfpc = pc pushed by mcount call.
   8.299 +     This identifies the function that was just entered.  */
   8.300 +  selfpc = (u32) reg[14].I;
   8.301 +  /* frompcindex = pc in preceding frame.
   8.302 +     This identifies the caller of the function just entered.  */
   8.303 +  frompcindex = (unsigned short *) reg[12].I;
   8.304 +  /*
   8.305 +   * check that we are profiling
   8.306 +   * and that we aren't recursively invoked.
   8.307 +   */
   8.308 +  if (profiling) {
   8.309 +    goto out;
   8.310 +  }
   8.311 +  profiling++;
   8.312 +  /*
   8.313 +   * check that frompcindex is a reasonable pc value.
   8.314 +   * for example: signal catchers get called from the stack,
   8.315 +   *   not from text space.  too bad.
   8.316 +   */
   8.317 +  frompcindex = (unsigned short *) ((long) frompcindex - (long) s_lowpc);
   8.318 +  if ((unsigned long) frompcindex > s_textsize) {
   8.319 +    goto done;
   8.320 +  }
   8.321 +  frompcindex =
   8.322 +    &froms[((long) frompcindex) / (HASHFRACTION * sizeof(*froms))];
   8.323 +  toindex = *frompcindex;
   8.324 +  if (toindex == 0) {
   8.325 +    /*
   8.326 +     * first time traversing this arc
   8.327 +     */
   8.328 +    toindex = ++tos[0].link;
   8.329 +    if (toindex >= tolimit) {
   8.330 +      goto overflow;
   8.331 +    }
   8.332 +    *frompcindex = (unsigned short)toindex;
   8.333 +    top = &tos[toindex];
   8.334 +    top->selfpc = selfpc;
   8.335 +    top->count = 1;
   8.336 +    top->link = 0;
   8.337 +    goto done;
   8.338 +  }
   8.339 +  top = &tos[toindex];
   8.340 +  if (top->selfpc == selfpc) {
   8.341 +    /*
   8.342 +     * arc at front of chain; usual case.
   8.343 +     */
   8.344 +    top->count++;
   8.345 +    goto done;
   8.346 +  }
   8.347 +  /*
   8.348 +   * have to go looking down chain for it.
   8.349 +   * top points to what we are looking at,
   8.350 +   * prevtop points to previous top.
   8.351 +   * we know it is not at the head of the chain.
   8.352 +   */
   8.353 +  for (; /* goto done */; ) {
   8.354 +    if (top->link == 0) {
   8.355 +      /*
   8.356 +       * top is end of the chain and none of the chain
   8.357 +       * had top->selfpc == selfpc.
   8.358 +       * so we allocate a new tostruct
   8.359 +       * and link it to the head of the chain.
   8.360 +       */
   8.361 +      toindex = ++tos[0].link;
   8.362 +      if (toindex >= tolimit) {
   8.363 +        goto overflow;
   8.364 +      }
   8.365 +      top = &tos[toindex];
   8.366 +      top->selfpc = selfpc;
   8.367 +      top->count = 1;
   8.368 +      top->link = *frompcindex;
   8.369 +      *frompcindex = (unsigned short)toindex;
   8.370 +      goto done;
   8.371 +    }
   8.372 +    /*
   8.373 +     * otherwise, check the next arc on the chain.
   8.374 +     */
   8.375 +    prevtop = top;
   8.376 +    top = &tos[top->link];
   8.377 +    if (top->selfpc == selfpc) {
   8.378 +      /*
   8.379 +       * there it is.
   8.380 +       * increment its count
   8.381 +       * move it to the head of the chain.
   8.382 +       */
   8.383 +      top->count++;
   8.384 +      toindex = prevtop->link;
   8.385 +      prevtop->link = top->link;
   8.386 +      top->link = *frompcindex;
   8.387 +      *frompcindex = (unsigned short)toindex;
   8.388 +      goto done;
   8.389 +    }
   8.390 +    
   8.391 +  }
   8.392 + done:
   8.393 +  profiling--;
   8.394 +  /* and fall through */
   8.395 + out:
   8.396 +  return;  /* normal return restores saved registers */
   8.397 +  
   8.398 + overflow:
   8.399 +  profiling++; /* halt further profiling */
   8.400 +#define TOLIMIT "mcount: tos overflow\n"
   8.401 +  systemMessage(0, TOLIMIT);
   8.402 +  goto out;
   8.403 +}
   8.404 +
   8.405 +void profSetHertz(int h)
   8.406 +{
   8.407 +  hz = h;
   8.408 +}
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/src/prof/prof.h	Sun Mar 04 22:32:01 2012 -0600
     9.3 @@ -0,0 +1,34 @@
     9.4 +// -*- C++ -*-
     9.5 +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
     9.6 +// Copyright (C) 1999-2003 Forgotten
     9.7 +// Copyright (C) 2004 Forgotten and the VBA development team
     9.8 +
     9.9 +// This program is free software; you can redistribute it and/or modify
    9.10 +// it under the terms of the GNU General Public License as published by
    9.11 +// the Free Software Foundation; either version 2, or(at your option)
    9.12 +// any later version.
    9.13 +//
    9.14 +// This program is distributed in the hope that it will be useful,
    9.15 +// but WITHOUT ANY WARRANTY; without even the implied warranty of
    9.16 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    9.17 +// GNU General Public License for more details.
    9.18 +//
    9.19 +// You should have received a copy of the GNU General Public License
    9.20 +// along with this program; if not, write to the Free Software Foundation,
    9.21 +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
    9.22 +
    9.23 +#ifndef VBA_PROF_PROF_H
    9.24 +#define VBA_PROF_PROF_H
    9.25 +
    9.26 +/* Control profiling;
    9.27 +   profiling is what mcount checks to see if
    9.28 +   all the data structures are ready.  */
    9.29 +
    9.30 +extern void profControl(int mode);
    9.31 +extern void profStartup(u32 lowpc, u32 highpc);
    9.32 +extern void profCleanup();
    9.33 +extern void profCount();
    9.34 +
    9.35 +extern void profSetHertz(int hertz);
    9.36 +#endif
    9.37 +
    10.1 --- a/src/sdl/Makefile.am	Sun Mar 04 21:09:22 2012 -0600
    10.2 +++ b/src/sdl/Makefile.am	Sun Mar 04 22:32:01 2012 -0600
    10.3 @@ -3,28 +3,37 @@
    10.4  #noinst_PROGRAMS = TestEmu
    10.5  
    10.6  VisualBoyAdvance_SOURCES = \
    10.7 -	SDL.cpp			\
    10.8 -	debugger.cpp		\
    10.9 -	debugger.h		\
   10.10 -	expr-lex.cpp		\
   10.11 -	expr.cpp		\
   10.12 -	expr.cpp.h		\
   10.13 -	exprNode.cpp		\
   10.14 -	exprNode.h		\
   10.15 -	getopt.c		\
   10.16 -	getopt.h		\
   10.17 -	getopt1.c		\
   10.18 -	../AutoBuild.h		\
   10.19 -	../NLS.h		\
   10.20 -	../Port.h
   10.21 +	Array.h		\
   10.22 +	debugger.h	\
   10.23 +	expr.cpp.h	\
   10.24 +	getopt.h	\
   10.25 +	RingBuffer.h	\
   10.26 +	SoundDriver.h	\
   10.27 +	SoundSDL.h	\
   10.28 +	Types.h		\
   10.29 +	exprNode.h	\
   10.30 +			\
   10.31 +	debugger.cpp	\
   10.32 +	expr.cpp	\
   10.33 +	expr-lex.cpp	\
   10.34 +	exprNode.cpp	\
   10.35 +	getopt1.c	\
   10.36 +	getopt.c	\
   10.37 +	SDL.cpp		\
   10.38 +	SoundSDL.cpp	
   10.39 +
   10.40 +
   10.41 +#TestEmu.cpp
   10.42 +
   10.43  
   10.44  VisualBoyAdvance_LDADD =   	\
   10.45 -	../lua/libgblua.a       \
   10.46  	../common/libgbcom.a	\
   10.47  	../gb/libgb.a		\
   10.48  	../gba/libgba.a		\
   10.49  	../filters/lib386.a 	\
   10.50 -	../filters/libfilter.a
   10.51 +	../filters/libfilter.a	\
   10.52 +	../prof/libprof.a	\
   10.53 +	../lua/libgblua.a       
   10.54  
   10.55  # TestEmu_SOURCES = \
   10.56  # 	TestEmu.cpp		\
   10.57 @@ -48,4 +57,4 @@
   10.58  	-DSDL				\
   10.59  	-DSYSCONFDIR=\"$(sysconfdir)\"
   10.60  
   10.61 -AM_CXXFLAGS = -fno-exceptions
   10.62 +AM_CXXFLAGS = -fno-exceptions @SDL_CFLAGS@
    11.1 --- a/src/sdl/SDL.cpp	Sun Mar 04 21:09:22 2012 -0600
    11.2 +++ b/src/sdl/SDL.cpp	Sun Mar 04 22:32:01 2012 -0600
    11.3 @@ -22,7 +22,7 @@
    11.4  #include <string.h>
    11.5  #include <sys/types.h>
    11.6  #include <sys/stat.h>
    11.7 -
    11.8 +#include <config.h>
    11.9  #include "AutoBuild.h"
   11.10  
   11.11  #include "Port.h"
   11.12 @@ -2043,7 +2043,7 @@
   11.13  
   11.14  int main(int argc, char **argv)
   11.15  {
   11.16 -  fprintf(stderr, "VisualBoyAdvance version %s [SDL]\n", VERSION);
   11.17 +  fprintf(stderr, "VisualBoyAdvance version %s [SDL]\n", PACKAGE_VERSION);
   11.18  
   11.19    arg0 = argv[0];
   11.20