diff options
author | Jeff Johnston <jjohnstn@redhat.com> | 2008-09-02 20:48:48 +0400 |
---|---|---|
committer | Jeff Johnston <jjohnstn@redhat.com> | 2008-09-02 20:48:48 +0400 |
commit | 2c73a5e682663e2eea5184bac36f1d8052038591 (patch) | |
tree | fe8e545f1dda482d3fbed953a4c405ffd26bd85a /newlib/libc/machine/spu | |
parent | f43d60be62737d17dea2a97001dec92899c5d8ae (diff) |
2008-09-01 Ken Werner <ken.werner@de.ibm.com>
* libc/machine/spu/include/spu_timer.h: spu_timebase function added.
* libc/machine/spu/spu_timebase.c: New file.
* libc/machine/spu/Makefile.am: Add new file.
* libc/machine/spu/Makefile.in: Regenerated.
Diffstat (limited to 'newlib/libc/machine/spu')
-rw-r--r-- | newlib/libc/machine/spu/Makefile.am | 2 | ||||
-rw-r--r-- | newlib/libc/machine/spu/Makefile.in | 24 | ||||
-rw-r--r-- | newlib/libc/machine/spu/include/spu_timer.h | 1 | ||||
-rw-r--r-- | newlib/libc/machine/spu/spu_timebase.c | 51 |
4 files changed, 69 insertions, 9 deletions
diff --git a/newlib/libc/machine/spu/Makefile.am b/newlib/libc/machine/spu/Makefile.am index fe4798e29..070779140 100644 --- a/newlib/libc/machine/spu/Makefile.am +++ b/newlib/libc/machine/spu/Makefile.am @@ -23,7 +23,7 @@ lib_a_SOURCES = setjmp.S assert.c clearerr.c creat.c fclose.c feof.c \ vsiscanf.c vsniprintf.c vsnprintf.c vsprintf.c vsscanf.c \ stack_reg_va.S spu_clock_svcs.c spu_clock_stop.c spu_timer_flih.S \ spu_timer_slih.c spu_timer_slih_reg.c spu_timer_svcs.c \ - spu_timer_stop.c spu_timer_free.c + spu_timer_stop.c spu_timer_free.c spu_timebase.c lib_a_CCASFLAGS = $(AM_CCASFLAGS) lib_a_CFLAGS = $(AM_CFLAGS) diff --git a/newlib/libc/machine/spu/Makefile.in b/newlib/libc/machine/spu/Makefile.in index 941f010fc..2eefed4b9 100644 --- a/newlib/libc/machine/spu/Makefile.in +++ b/newlib/libc/machine/spu/Makefile.in @@ -78,7 +78,7 @@ DIST_COMMON = $(srcdir)/../../../../config.guess \ $(srcdir)/../../../../compile $(srcdir)/../../../../compile \ $(srcdir)/../../../../compile $(srcdir)/../../../../compile \ $(srcdir)/../../../../compile $(srcdir)/../../../../compile \ - $(srcdir)/../../../../compile + $(srcdir)/../../../../compile $(srcdir)/../../../../compile subdir = . ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/../../../acinclude.m4 \ @@ -140,7 +140,7 @@ am_lib_a_OBJECTS = lib_a-setjmp.$(OBJEXT) lib_a-assert.$(OBJEXT) \ lib_a-spu_timer_flih.$(OBJEXT) lib_a-spu_timer_slih.$(OBJEXT) \ lib_a-spu_timer_slih_reg.$(OBJEXT) \ lib_a-spu_timer_svcs.$(OBJEXT) lib_a-spu_timer_stop.$(OBJEXT) \ - lib_a-spu_timer_free.$(OBJEXT) + lib_a-spu_timer_free.$(OBJEXT) lib_a-spu_timebase.$(OBJEXT) lib_a_OBJECTS = $(am_lib_a_OBJECTS) DEFAULT_INCLUDES = -I. -I$(srcdir) depcomp = @@ -214,11 +214,6 @@ STRIP = @STRIP@ USE_LIBTOOL_FALSE = @USE_LIBTOOL_FALSE@ USE_LIBTOOL_TRUE = @USE_LIBTOOL_TRUE@ VERSION = @VERSION@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_AS = @ac_ct_AS@ -ac_ct_RANLIB = @ac_ct_RANLIB@ -ac_ct_READELF = @ac_ct_READELF@ -ac_ct_STRIP = @ac_ct_STRIP@ aext = @aext@ am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ @@ -234,18 +229,23 @@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ +htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ libm_machine_dir = @libm_machine_dir@ +localedir = @localedir@ localstatedir = @localstatedir@ lpfx = @lpfx@ machine_dir = @machine_dir@ @@ -254,8 +254,10 @@ mkdir_p = @mkdir_p@ newlib_basedir = @newlib_basedir@ oext = @oext@ oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ +psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ sys_dir = @sys_dir@ @@ -280,7 +282,7 @@ lib_a_SOURCES = setjmp.S assert.c clearerr.c creat.c fclose.c feof.c \ vsiscanf.c vsniprintf.c vsnprintf.c vsprintf.c vsscanf.c \ stack_reg_va.S spu_clock_svcs.c spu_clock_stop.c spu_timer_flih.S \ spu_timer_slih.c spu_timer_slih_reg.c spu_timer_svcs.c \ - spu_timer_stop.c spu_timer_free.c + spu_timer_stop.c spu_timer_free.c spu_timebase.c lib_a_CCASFLAGS = $(AM_CCASFLAGS) lib_a_CFLAGS = $(AM_CFLAGS) @@ -912,6 +914,12 @@ lib_a-spu_timer_free.o: spu_timer_free.c lib_a-spu_timer_free.obj: spu_timer_free.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-spu_timer_free.obj `if test -f 'spu_timer_free.c'; then $(CYGPATH_W) 'spu_timer_free.c'; else $(CYGPATH_W) '$(srcdir)/spu_timer_free.c'; fi` + +lib_a-spu_timebase.o: spu_timebase.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-spu_timebase.o `test -f 'spu_timebase.c' || echo '$(srcdir)/'`spu_timebase.c + +lib_a-spu_timebase.obj: spu_timebase.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-spu_timebase.obj `if test -f 'spu_timebase.c'; then $(CYGPATH_W) 'spu_timebase.c'; else $(CYGPATH_W) '$(srcdir)/spu_timebase.c'; fi` uninstall-info-am: ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) diff --git a/newlib/libc/machine/spu/include/spu_timer.h b/newlib/libc/machine/spu/include/spu_timer.h index ea10ce57d..4116aac9f 100644 --- a/newlib/libc/machine/spu/include/spu_timer.h +++ b/newlib/libc/machine/spu/include/spu_timer.h @@ -47,6 +47,7 @@ extern int spu_timer_alloc (int interval, void (*func) (int)); extern int spu_timer_free (int id); extern int spu_timer_start (int id); extern int spu_timer_stop (int id); +extern unsigned spu_timebase (void); /* Interrupt services. */ extern void spu_slih_register (unsigned event_mask, diff --git a/newlib/libc/machine/spu/spu_timebase.c b/newlib/libc/machine/spu/spu_timebase.c new file mode 100644 index 000000000..cb8f34d94 --- /dev/null +++ b/newlib/libc/machine/spu/spu_timebase.c @@ -0,0 +1,51 @@ +/* +(C) Copyright IBM Corp. 2008 + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, +this list of conditions and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. +* Neither the name of IBM nor the names of its contributors may be +used to endorse or promote products derived from this software without +specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. +*/ + +#include <spu_timer.h> +#include <stdio.h> + +/* This function queries /proc/cpuinfo and returns the SPU time base in + Hertz. */ +unsigned int +spu_timebase (void) +{ + FILE *f; + unsigned tb = 0; + char line[64]; + if ((f = fopen ("/proc/cpuinfo", "r"))) + { + while (fgets (line, sizeof (line), f)) + if (sscanf (line, "timebase : %u", &tb)) + break; + fclose (f); + } + return (tb); +} + |