commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r10098 - in gnuradio/trunk: . config gnuradio-core/src


From: jcorgan
Subject: [Commit-gnuradio] r10098 - in gnuradio/trunk: . config gnuradio-core/src/lib/filter gnuradio-core/src/lib/missing
Date: Mon, 1 Dec 2008 13:03:39 -0700 (MST)

Author: jcorgan
Date: 2008-12-01 13:03:38 -0700 (Mon, 01 Dec 2008)
New Revision: 10098

Added:
   gnuradio/trunk/config/gr_check_memalign.m4
   gnuradio/trunk/gnuradio-core/src/lib/missing/posix_memalign.cc
   gnuradio/trunk/gnuradio-core/src/lib/missing/posix_memalign.h
Modified:
   gnuradio/trunk/config/grc_gnuradio_core.m4
   gnuradio/trunk/configure.ac
   gnuradio/trunk/gnuradio-core/src/lib/filter/gr_fir_fff_altivec.cc
   gnuradio/trunk/gnuradio-core/src/lib/missing/Makefile.am
Log:
Merged r9798:9801 from michaelld/memalign into trunk.  Passes distcheck on 
Ubuntu 8.10.

Copied: gnuradio/trunk/config/gr_check_memalign.m4 (from rev 9801, 
gnuradio/branches/developers/michaelld/memalign/config/gr_check_memalign.m4)
===================================================================
--- gnuradio/trunk/config/gr_check_memalign.m4                          (rev 0)
+++ gnuradio/trunk/config/gr_check_memalign.m4  2008-12-01 20:03:38 UTC (rev 
10098)
@@ -0,0 +1,40 @@
+# Copyright 2008 Free Software Foundation, Inc.
+
+# This program 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.
+
+# This program 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 this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Boston, MA
+# 02110-1301, USA.
+
+AC_DEFUN([GR_CHECK_MEMALIGN],
+[
+  # Check for allocing memory alignment functions
+  # If 'posix_memalign' is available, use it solely.
+  AC_CHECK_FUNCS([posix_memalign],,[
+    # Otherwise, check for valloc and the
+    # (a-priori known) alignment of 'malloc'
+    AC_CHECK_FUNCS([valloc])
+    aligned_malloc=0
+    # 'malloc' is 16-byte aligned on (at least) Darwin 8 and 9
+    case "$host_os" in
+      darwin8*) aligned_malloc=16 ;;
+      darwin9*) aligned_malloc=16 ;;
+      *) ;;
+    esac
+    if test $aligned_malloc = 0; then
+      AC_MSG_RESULT([malloc has unknown alignment.])
+    else
+      AC_MSG_RESULT([malloc is $aligned_malloc-byte aligned.])
+    fi
+    AC_DEFINE_UNQUOTED([ALIGNED_MALLOC],[$aligned_malloc],[Define as the 
alignment of malloc if known; otherwise 0.])
+  ])
+])

Modified: gnuradio/trunk/config/grc_gnuradio_core.m4
===================================================================
--- gnuradio/trunk/config/grc_gnuradio_core.m4  2008-11-30 23:55:36 UTC (rev 
10097)
+++ gnuradio/trunk/config/grc_gnuradio_core.m4  2008-12-01 20:03:38 UTC (rev 
10098)
@@ -55,6 +55,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/trunk/configure.ac
===================================================================
--- gnuradio/trunk/configure.ac 2008-11-30 23:55:36 UTC (rev 10097)
+++ gnuradio/trunk/configure.ac 2008-12-01 20:03:38 UTC (rev 10098)
@@ -141,6 +141,7 @@
 
 dnl Checks for library functions.
 AC_FUNC_ALLOCA
+GR_CHECK_MEMALIGN
 AC_FUNC_SETVBUF_REVERSED
 AC_FUNC_VPRINTF
 AC_CHECK_FUNCS([mmap select socket strcspn strerror strspn getpagesize 
sysconf])

Modified: gnuradio/trunk/gnuradio-core/src/lib/filter/gr_fir_fff_altivec.cc
===================================================================
--- gnuradio/trunk/gnuradio-core/src/lib/filter/gr_fir_fff_altivec.cc   
2008-11-30 23:55:36 UTC (rev 10097)
+++ gnuradio/trunk/gnuradio-core/src/lib/filter/gr_fir_fff_altivec.cc   
2008-12-01 20:03:38 UTC (rev 10098)
@@ -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/trunk/gnuradio-core/src/lib/missing/Makefile.am
===================================================================
--- gnuradio/trunk/gnuradio-core/src/lib/missing/Makefile.am    2008-11-30 
23:55:36 UTC (rev 10097)
+++ gnuradio/trunk/gnuradio-core/src/lib/missing/Makefile.am    2008-12-01 
20:03:38 UTC (rev 10098)
@@ -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.cc       \
+       posix_memalign.h        \
+       usleep.c                
 
 noinst_LTLIBRARIES = libmissing.la
 
 libmissing_la_SOURCES =        \
-       bug_work_around_8.cc    
+       bug_work_around_8.cc    \
+       posix_memalign.cc       

Copied: gnuradio/trunk/gnuradio-core/src/lib/missing/posix_memalign.cc (from 
rev 9801, 
gnuradio/branches/developers/michaelld/memalign/gnuradio-core/src/lib/missing/posix_memalign.cc)
===================================================================
--- gnuradio/trunk/gnuradio-core/src/lib/missing/posix_memalign.cc              
                (rev 0)
+++ gnuradio/trunk/gnuradio-core/src/lib/missing/posix_memalign.cc      
2008-12-01 20:03:38 UTC (rev 10098)
@@ -0,0 +1,109 @@
+/* -*- 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 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);
+  *memptr = (void*) 0;
+
+  /* make sure 'alignment' is a power of 2
+   * and multiple of sizeof (void*)
+   */
+
+  /* make sure 'alignment' is a multiple of sizeof (void*) */
+  if ((alignment % sizeof (void*)) != 0)
+    return (EINVAL);
+
+  /* make sure 'alignment' is a power of 2 */
+  if ((alignment & (alignment - 1)) != 0)
+    return (EINVAL);
+
+  /* good alignment */
+
+#if (ALIGNED_MALLOC != 0)
+
+  /* if 'malloc' is known to be aligned, and the desired 'alignment'
+   * matches is <= that provided by 'malloc', then use 'malloc'.  This
+   * works on, e.g., Darwin 8 & 9: for which malloc is 16-byte aligned.
+   */
+  size_t am = (size_t) ALIGNED_MALLOC;
+  if (alignment <= am) {
+    /* make sure ALIGNED_MALLOC is a power of 2, to guarantee that the
+     * alignment is correct (since 'alignment' must be a power of 2).
+     */
+    if ((am & (am - 1)) != 0)
+      return (EINVAL);
+    /* good malloc alignment */
+    *memptr = malloc (size);
+  }
+
+#endif /* (ALIGNED_MALLOC != 0) */
+#ifdef HAVE_VALLOC
+
+  if (*memptr == (void*) 0) {
+    /* try valloc if it exists */
+    /* cheap and easy way to make sure alignment is met, so long as it
+     * is <= pagesize () */
+    if (alignment <= (size_t) gr_pagesize ()) {
+      *memptr = valloc (size);
+    }
+  }
+
+#endif /* HAVE_VALLOC */
+
+#if (ALIGNED_MALLOC == 0) && !defined (HAVE_VALLOC)
+  /* no posix_memalign, valloc, and malloc isn't known to be aligned
+   * (enough for the input arguments); no idea what to do.
+   */
+
+#error gnuradio-core/src/libmissing/posix_memalign.cc: Cannot find a way to 
alloc aligned memory.
+
+#endif
+
+  /* if the pointer wasn't allocated properly, return that there was
+   * not enough memory to allocate; otherwise, return OK (0).
+   */
+  if (*memptr == (void*) 0)
+    return (ENOMEM);
+  else
+    return (0);
+};
+
+#endif /* ! HAVE_POSIX_MEMALIGN */

Copied: gnuradio/trunk/gnuradio-core/src/lib/missing/posix_memalign.h (from rev 
9801, 
gnuradio/branches/developers/michaelld/memalign/gnuradio-core/src/lib/missing/posix_memalign.h)
===================================================================
--- gnuradio/trunk/gnuradio-core/src/lib/missing/posix_memalign.h               
                (rev 0)
+++ gnuradio/trunk/gnuradio-core/src/lib/missing/posix_memalign.h       
2008-12-01 20:03:38 UTC (rev 10098)
@@ -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]