commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r9623 - in gnuradio/branches/developers/michaelld/posi


From: michaelld
Subject: [Commit-gnuradio] r9623 - in gnuradio/branches/developers/michaelld/posix_memalign: . config gnuradio-core/src/lib/filter gnuradio-core/src/lib/missing
Date: Sat, 20 Sep 2008 13:27:40 -0600 (MDT)

Author: michaelld
Date: 2008-09-20 13:27:40 -0600 (Sat, 20 Sep 2008)
New Revision: 9623

Added:
   
gnuradio/branches/developers/michaelld/posix_memalign/gnuradio-core/src/lib/missing/posix_memalign.c
   
gnuradio/branches/developers/michaelld/posix_memalign/gnuradio-core/src/lib/missing/posix_memalign.h
Modified:
   
gnuradio/branches/developers/michaelld/posix_memalign/config/grc_gnuradio_core.m4
   gnuradio/branches/developers/michaelld/posix_memalign/configure.ac
   
gnuradio/branches/developers/michaelld/posix_memalign/gnuradio-core/src/lib/filter/gr_fir_fff_altivec.cc
   
gnuradio/branches/developers/michaelld/posix_memalign/gnuradio-core/src/lib/missing/Makefile.am
Log:
First try at adding posix_memalign emulation to missing library.



Modified: 
gnuradio/branches/developers/michaelld/posix_memalign/config/grc_gnuradio_core.m4
===================================================================
--- 
gnuradio/branches/developers/michaelld/posix_memalign/config/grc_gnuradio_core.m4
   2008-09-20 19:08:48 UTC (rev 9622)
+++ 
gnuradio/branches/developers/michaelld/posix_memalign/config/grc_gnuradio_core.m4
   2008-09-20 19:27:40 UTC (rev 9623)
@@ -46,6 +46,7 @@
 -I\${abs_top_builddir}/gnuradio-core/src/lib/gengen \
 -I\${abs_top_srcdir}/gnuradio-core/src/lib/filter \
 -I\${abs_top_builddir}/gnuradio-core/src/lib/filter \
+-I\${abs_top_srcdir}/gnuradio-core/src/lib/missing \
 -I\${abs_top_srcdir}/gnuradio-core/src/lib/reed-solomon \
 -I\${abs_top_srcdir}/gnuradio-core/src/lib/viterbi \
 -I\${abs_top_srcdir}/gnuradio-core/src/lib/io \

Modified: gnuradio/branches/developers/michaelld/posix_memalign/configure.ac
===================================================================
--- gnuradio/branches/developers/michaelld/posix_memalign/configure.ac  
2008-09-20 19:08:48 UTC (rev 9622)
+++ gnuradio/branches/developers/michaelld/posix_memalign/configure.ac  
2008-09-20 19:27:40 UTC (rev 9623)
@@ -146,7 +146,7 @@
 AC_CHECK_FUNCS([mmap select socket strcspn strerror strspn getpagesize 
sysconf])
 AC_CHECK_FUNCS([snprintf gettimeofday nanosleep sched_setscheduler])
 AC_CHECK_FUNCS([modf sqrt sigaction sigprocmask pthread_sigmask])
-AC_CHECK_FUNCS([sched_setaffinity])
+AC_CHECK_FUNCS([sched_setaffinity posix_memalign valloc])
 
 AC_CHECK_LIB(m, sincos, [AC_DEFINE([HAVE_SINCOS],[1],[Define to 1 if your 
system has `sincos'.])])
 AC_CHECK_LIB(m, sincosf,[AC_DEFINE([HAVE_SINCOSF],[1],[Define to 1 if your 
system has `sincosf'.])])

Modified: 
gnuradio/branches/developers/michaelld/posix_memalign/gnuradio-core/src/lib/filter/gr_fir_fff_altivec.cc
===================================================================
--- 
gnuradio/branches/developers/michaelld/posix_memalign/gnuradio-core/src/lib/filter/gr_fir_fff_altivec.cc
    2008-09-20 19:08:48 UTC (rev 9622)
+++ 
gnuradio/branches/developers/michaelld/posix_memalign/gnuradio-core/src/lib/filter/gr_fir_fff_altivec.cc
    2008-09-20 19:27:40 UTC (rev 9623)
@@ -23,12 +23,12 @@
 #include <config.h>
 #endif
 #include <gr_fir_fff_altivec.h>
-#include <stdlib.h>
 #include <stdexcept>
 #include <assert.h>
 #include <gr_math.h>
 #include <gr_altivec.h>
 #include <dotprod_fff_altivec.h>
+#include "posix_memalign.h"
 
 gr_fir_fff_altivec::gr_fir_fff_altivec()
   : gr_fir_fff_generic(),

Modified: 
gnuradio/branches/developers/michaelld/posix_memalign/gnuradio-core/src/lib/missing/Makefile.am
===================================================================
--- 
gnuradio/branches/developers/michaelld/posix_memalign/gnuradio-core/src/lib/missing/Makefile.am
     2008-09-20 19:08:48 UTC (rev 9622)
+++ 
gnuradio/branches/developers/michaelld/posix_memalign/gnuradio-core/src/lib/missing/Makefile.am
     2008-09-20 19:27:40 UTC (rev 9623)
@@ -1,5 +1,5 @@
 #
-# Copyright 2003,2004 Free Software Foundation, Inc.
+# Copyright 2003,2004,2008 Free Software Foundation, Inc.
 # 
 # This file is part of GNU Radio
 # 
@@ -21,13 +21,18 @@
 
 include $(top_srcdir)/Makefile.common
 
+AM_CPPFLAGS = $(GNURADIO_INCLUDES) $(WITH_INCLUDES)
+
 EXTRA_DIST =                   \
        getopt.h                \
        getopt.c                \
        gettimeofday.c          \
-       usleep.c
+       posix_memalign.c        \
+       posix_memalign.h        \
+       usleep.c                
 
 noinst_LTLIBRARIES = libmissing.la
 
 libmissing_la_SOURCES =        \
-       bug_work_around_8.cc    
+       bug_work_around_8.cc    \
+       posix_memalign.c
\ No newline at end of file

Added: 
gnuradio/branches/developers/michaelld/posix_memalign/gnuradio-core/src/lib/missing/posix_memalign.c
===================================================================
--- 
gnuradio/branches/developers/michaelld/posix_memalign/gnuradio-core/src/lib/missing/posix_memalign.c
                                (rev 0)
+++ 
gnuradio/branches/developers/michaelld/posix_memalign/gnuradio-core/src/lib/missing/posix_memalign.c
        2008-09-20 19:27:40 UTC (rev 9623)
@@ -0,0 +1,78 @@
+/* -*- c++ -*- */
+/*
+ * 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "posix_memalign.h"
+
+#ifndef HAVE_POSIX_MEMALIGN
+
+/* emulate posix_memalign functionality, to some degree */
+
+#include <errno.h>
+#include "gr_pagesize.h"
+
+int gr_posix_memalign
+(void **memptr, size_t alignment, size_t size)
+{
+  /* emulate posix_memalign functionality, to some degree */
+
+  /* make sure the return handle is valid; return "bad address" if not valid */
+  if (memptr == 0)
+    return (EFAULT);
+
+  /* make sure the alignment is a power of 2 multiple of sizeof (void*) */
+
+  /* make sure the alignment is divisiable by sizeof (void*) */
+  if ((alignment % sizeof (void*)) != 0)
+    return (EINVAL);
+  size_t a2 = alignment / sizeof (void*);
+  /* make sure remainder is a power of 2 */
+  if ((a2 & (a2 - 1)) != 0)
+    return (EINVAL);
+  /* good alignment */
+
+#ifdef HAVE_VALLOC
+
+  /* cheap and easy way to make sure alignment is met, so long as it
+   * is <= pagesize () */
+  if (alignment > (size_t) gr_pagesize ())
+    return (EINVAL);
+  *memptr = valloc (size);
+
+#else
+
+  /* no posix_memalign or valloc; no idea what to do. */
+
+#error gr_posix_memalign: Cannot find a way to alloc aligned memory.
+
+#endif /* HAVE_VALLOC */
+
+  if (*memptr == 0)
+    return (ENOMEM);
+  else
+    return (0);
+};
+
+#endif /* ! HAVE_POSIX_MEMALIGN */

Added: 
gnuradio/branches/developers/michaelld/posix_memalign/gnuradio-core/src/lib/missing/posix_memalign.h
===================================================================
--- 
gnuradio/branches/developers/michaelld/posix_memalign/gnuradio-core/src/lib/missing/posix_memalign.h
                                (rev 0)
+++ 
gnuradio/branches/developers/michaelld/posix_memalign/gnuradio-core/src/lib/missing/posix_memalign.h
        2008-09-20 19:27:40 UTC (rev 9623)
@@ -0,0 +1,42 @@
+/* -*- c++ -*- */
+/*
+ * 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.
+ */
+
+#ifndef _POSIX_MEMALIGN_H_
+#define _POSIX_MEMALIGN_H_
+
+#include <stdlib.h>
+
+#ifndef HAVE_POSIX_MEMALIGN
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern int posix_memalign (void** memptr, size_t alignment, size_t size);
+
+#ifdef __cplusplus
+};
+#endif
+
+#endif /* ! HAVE_POSIX_MEMALIGN */
+
+#endif /* _POSIX_MEMALIGN_H_ */





reply via email to

[Prev in Thread] Current Thread [Next in Thread]