diff options
author | jcorgan | 2008-06-20 18:14:47 +0000 |
---|---|---|
committer | jcorgan | 2008-06-20 18:14:47 +0000 |
commit | b48de00cfefac61414b0ea568e5014f2794e50cd (patch) | |
tree | 95a5f8062f76022d7618eaa281ac6ebaf72d1586 | |
parent | 8b04fb2beeae36bbbb8d66ce95dea7df8edb65be (diff) | |
download | gnuradio-b48de00cfefac61414b0ea568e5014f2794e50cd.tar.gz gnuradio-b48de00cfefac61414b0ea568e5014f2794e50cd.tar.bz2 gnuradio-b48de00cfefac61414b0ea568e5014f2794e50cd.zip |
Merged -r8639:8641 from jcorgan/gruel into trunk. Adds libgruel, the GNU Radio Utility Etcetera Library. See README for description.
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@8642 221aa14e-8319-0410-a670-987f0aec2ac5
-rw-r--r-- | Makefile.common | 4 | ||||
-rw-r--r-- | config/Makefile.am | 1 | ||||
-rw-r--r-- | config/grc_gruel.m4 | 44 | ||||
-rw-r--r-- | configure.ac | 1 | ||||
-rw-r--r-- | gruel/AUTHORS | 1 | ||||
-rw-r--r-- | gruel/ChangeLog | 20 | ||||
-rw-r--r-- | gruel/Makefile.am | 30 | ||||
-rw-r--r-- | gruel/README | 30 | ||||
-rw-r--r-- | gruel/gruel.pc.in | 11 | ||||
-rw-r--r-- | gruel/src/Makefile.am | 22 | ||||
-rw-r--r-- | gruel/src/include/Makefile.am | 22 | ||||
-rw-r--r-- | gruel/src/include/gruel/Makefile.am | 27 | ||||
-rw-r--r-- | gruel/src/include/gruel/realtime.h | 44 | ||||
-rw-r--r-- | gruel/src/lib/Makefile.am | 39 | ||||
-rw-r--r-- | gruel/src/lib/realtime.cc | 112 |
15 files changed, 408 insertions, 0 deletions
diff --git a/Makefile.common b/Makefile.common index 0ee6f2bf3..a4a3139c6 100644 --- a/Makefile.common +++ b/Makefile.common @@ -73,6 +73,10 @@ GNURADIO_CORE_LA = @gnuradio_core_LA@ GNURADIO_I = @gnuradio_core_I@ # How to link in the USRP library from inside the tree +GRUEL_INCLUDES = @gruel_INCLUDES@ +GRUEL_LA = @gruel_LA@ + +# How to link in the USRP library from inside the tree USRP_INCLUDES = @usrp_INCLUDES@ USRP_LA = @usrp_LA@ diff --git a/config/Makefile.am b/config/Makefile.am index 4e87bc458..310568bfb 100644 --- a/config/Makefile.am +++ b/config/Makefile.am @@ -53,6 +53,7 @@ m4macros = \ grc_gr_video_sdl.m4 \ grc_gr_wxgui.m4 \ grc_mblock.m4 \ + grc_gruel.m4 \ gr_check_createfilemapping.m4 \ gr_check_mc4020.m4 \ gr_check_shm_open.m4 \ diff --git a/config/grc_gruel.m4 b/config/grc_gruel.m4 new file mode 100644 index 000000000..81f53ce13 --- /dev/null +++ b/config/grc_gruel.m4 @@ -0,0 +1,44 @@ +dnl Copyright 2001,2002,2003,2004,2005,2006,2008 Free Software Foundation, Inc. +dnl +dnl This file is part of GNU Radio +dnl +dnl GNU Radio is free software; you can redistribute it and/or modify +dnl it under the terms of the GNU General Public License as published by +dnl the Free Software Foundation; either version 3, or (at your option) +dnl any later version. +dnl +dnl GNU Radio is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with GNU Radio; see the file COPYING. If not, write to +dnl the Free Software Foundation, Inc., 51 Franklin Street, +dnl Boston, MA 02110-1301, USA. + +AC_DEFUN([GRC_GRUEL],[ + GRC_ENABLE(gruel) + GRC_WITH(gruel) + + dnl If execution gets to here, $passed will be: + dnl with : if the --with code didn't error out + dnl yes : if the --enable code passed muster and all dependencies are met + dnl no : otherwise + if test $passed != with; then + dnl how and where to find INCLUDES and LA + gruel_INCLUDES="-I\${abs_top_srcdir}/gruel/src/include" + gruel_LA="\${abs_top_builddir}/gruel/src/lib/libgruel.la" + fi + + AC_CONFIG_FILES([\ + gruel/Makefile \ + gruel/gruel.pc \ + gruel/src/Makefile \ + gruel/src/include/Makefile \ + gruel/src/include/gruel/Makefile \ + gruel/src/lib/Makefile \ + ]) + + GRC_BUILD_CONDITIONAL(gruel,[]) +]) diff --git a/configure.ac b/configure.ac index 9160b4ca4..f20ca9e4e 100644 --- a/configure.ac +++ b/configure.ac @@ -239,6 +239,7 @@ AC_ARG_ENABLE( ) build_dirs="config" +GRC_GRUEL dnl must come first GRC_OMNITHREAD dnl must come before gnuradio-core and mblock GRC_GCELL GRC_GNURADIO_CORE diff --git a/gruel/AUTHORS b/gruel/AUTHORS new file mode 100644 index 000000000..18e03c4a9 --- /dev/null +++ b/gruel/AUTHORS @@ -0,0 +1 @@ +Johnathan Corgan <jcorgan@corganenterprises.com> diff --git a/gruel/ChangeLog b/gruel/ChangeLog new file mode 100644 index 000000000..b185665ee --- /dev/null +++ b/gruel/ChangeLog @@ -0,0 +1,20 @@ +# +# Copyright 2008 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# diff --git a/gruel/Makefile.am b/gruel/Makefile.am new file mode 100644 index 000000000..93f56a7db --- /dev/null +++ b/gruel/Makefile.am @@ -0,0 +1,30 @@ +# +# Copyright 2008 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +include $(top_srcdir)/Makefile.common + +EXTRA_DIST = \ + gruel.pc.in + +SUBDIRS = src + +pkgconfigdir = $(libdir)/pkgconfig +pkgconfig_DATA = gruel.pc diff --git a/gruel/README b/gruel/README new file mode 100644 index 000000000..585cf026a --- /dev/null +++ b/gruel/README @@ -0,0 +1,30 @@ +# +# Copyright 2008 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +The GNU Radio Utility Etcetera Library, a collection of low-level routines +to avoid dependencies on the full GNU Radio core or other libraries. + +Over time, some code from libgnuradio-core, libpmt, libmblock, libusrp, +and libusrp2 will migrate here, to avoid duplication of code and simplify +dependencies. + +By design, this library will not have dependencies on any other part +of GNU Radio, but may have external dependencies such as Boost. diff --git a/gruel/gruel.pc.in b/gruel/gruel.pc.in new file mode 100644 index 000000000..6377f5bb3 --- /dev/null +++ b/gruel/gruel.pc.in @@ -0,0 +1,11 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: gruel +Description: The GNU Radio Utility Etcetera Library +Requires: +Version: @VERSION@ +Libs: -L${libdir} -lgruel +Cflags: -I${includedir} diff --git a/gruel/src/Makefile.am b/gruel/src/Makefile.am new file mode 100644 index 000000000..90c0f88bd --- /dev/null +++ b/gruel/src/Makefile.am @@ -0,0 +1,22 @@ +# +# Copyright 2008 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +SUBDIRS = include lib diff --git a/gruel/src/include/Makefile.am b/gruel/src/include/Makefile.am new file mode 100644 index 000000000..7a178810a --- /dev/null +++ b/gruel/src/include/Makefile.am @@ -0,0 +1,22 @@ +# +# Copyright 2008 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +SUBDIRS = gruel diff --git a/gruel/src/include/gruel/Makefile.am b/gruel/src/include/gruel/Makefile.am new file mode 100644 index 000000000..8ea484ced --- /dev/null +++ b/gruel/src/include/gruel/Makefile.am @@ -0,0 +1,27 @@ +# +# Copyright 2008 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +include $(top_srcdir)/Makefile.common + +gruelincludedir = $(prefix)/include/gruel + +gruelinclude_HEADERS = \ + realtime.h diff --git a/gruel/src/include/gruel/realtime.h b/gruel/src/include/gruel/realtime.h new file mode 100644 index 000000000..ded70ed0d --- /dev/null +++ b/gruel/src/include/gruel/realtime.h @@ -0,0 +1,44 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_REALTIME_H +#define INCLUDED_REALTIME_H + +namespace gruel { + + typedef enum { + RT_OK = 0, + RT_NOT_IMPLEMENTED, + RT_NO_PRIVS, + RT_OTHER_ERROR + } rt_status_t; + + /*! + * \brief If possible, enable high-priority "real time" scheduling. + * \ingroup misc + */ + rt_status_t + enable_realtime_scheduling(); + +} // namespace gruel + +#endif /* INCLUDED_GR_REALTIME_H */ diff --git a/gruel/src/lib/Makefile.am b/gruel/src/lib/Makefile.am new file mode 100644 index 000000000..972ff4ca9 --- /dev/null +++ b/gruel/src/lib/Makefile.am @@ -0,0 +1,39 @@ +# +# Copyright 2008 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +include $(top_srcdir)/Makefile.common + +AM_CPPFLAGS = $(DEFINES) $(BOOST_CFLAGS) $(GRUEL_INCLUDES) $(WITH_INCLUDES) + +lib_LTLIBRARIES = libgruel.la + +# These are the source files that go into the gruel shared library +libgruel_la_SOURCES = \ + realtime.cc + +# magic flags +libgruel_la_LDFLAGS = $(NO_UNDEFINED) + +# link the library against the c++ standard library +libgruel_la_LIBADD = \ + -lstdc++ + +noinst_HEADERS = diff --git a/gruel/src/lib/realtime.cc b/gruel/src/lib/realtime.cc new file mode 100644 index 000000000..bdcb31ab6 --- /dev/null +++ b/gruel/src/lib/realtime.cc @@ -0,0 +1,112 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,2007 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <gruel/realtime.h> + +#ifdef HAVE_SCHED_H +#include <sched.h> +#endif + +#include <string.h> +#include <errno.h> +#include <stdio.h> + +#if defined(HAVE_SCHED_SETSCHEDULER) + +namespace gruel { + + rt_status_t + enable_realtime_scheduling() + { + int policy = SCHED_FIFO; + int pri = (sched_get_priority_max (policy) + sched_get_priority_min (policy)) / 2; + int pid = 0; // this process + + struct sched_param param; + memset(¶m, 0, sizeof(param)); + param.sched_priority = pri; + int result = sched_setscheduler(pid, policy, ¶m); + if (result != 0){ + if (errno == EPERM) + return RT_NO_PRIVS; + else { + perror ("sched_setscheduler: failed to set real time priority"); + return RT_OTHER_ERROR; + } + } + + //printf("SCHED_FIFO enabled with priority = %d\n", pri); + return RT_OK; + } + +} // namespace gruel + +#elif defined(HAVE_PTHREAD_SETSCHEDPARAM) + +#include <pthread.h> +#include <stdio.h> + +namespace gruel { + + rt_status_t + enable_realtime_scheduling() + { + int policy = SCHED_FIFO; + int pri = (sched_get_priority_max (policy) + + sched_get_priority_min (policy)) / 2; + pthread_t this_thread = pthread_self (); // this process + struct sched_param param; + memset (¶m, 0, sizeof (param)); + param.sched_priority = pri; + int result = pthread_setschedparam (this_thread, policy, ¶m); + if (result != 0) { + if (errno == EPERM) + return RT_NO_PRIVS; + else { + perror ("pthread_setschedparam: failed to set real time priority"); + return RT_OTHER_ERROR; + } + } + + //printf("SCHED_FIFO enabled with priority = %d\n", pri); + return RT_OK; + } +} // namespace gruel + +// #elif // could try negative niceness + +#else + +namespace gruel { + + rt_status_t + enable_realtime_scheduling() + { + return RT_NOT_IMPLEMENTED; + } +} // namespace gruel + +#endif |