[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r9630 - gnuradio/branches/developers/michaelld/posix_m
From: |
michaelld |
Subject: |
[Commit-gnuradio] r9630 - gnuradio/branches/developers/michaelld/posix_memalign/gnuradio-core/src/lib/missing |
Date: |
Sun, 21 Sep 2008 08:59:50 -0600 (MDT) |
Author: michaelld
Date: 2008-09-21 08:59:48 -0600 (Sun, 21 Sep 2008)
New Revision: 9630
Added:
gnuradio/branches/developers/michaelld/posix_memalign/gnuradio-core/src/lib/missing/posix_memalign.cc
Removed:
gnuradio/branches/developers/michaelld/posix_memalign/gnuradio-core/src/lib/missing/posix_memalign.c
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/posix_memalign.h
Log:
Moved to C++ function, in order to make use of gr_pagesize (which is a
C++ function).
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-21 00:45:29 UTC (rev 9629)
+++
gnuradio/branches/developers/michaelld/posix_memalign/gnuradio-core/src/lib/missing/Makefile.am
2008-09-21 14:59:48 UTC (rev 9630)
@@ -27,7 +27,7 @@
getopt.h \
getopt.c \
gettimeofday.c \
- posix_memalign.c \
+ posix_memalign.cc \
posix_memalign.h \
usleep.c
@@ -35,4 +35,4 @@
libmissing_la_SOURCES = \
bug_work_around_8.cc \
- posix_memalign.c
\ No newline at end of file
+ posix_memalign.cc
Deleted:
gnuradio/branches/developers/michaelld/posix_memalign/gnuradio-core/src/lib/missing/posix_memalign.c
Added:
gnuradio/branches/developers/michaelld/posix_memalign/gnuradio-core/src/lib/missing/posix_memalign.cc
===================================================================
---
gnuradio/branches/developers/michaelld/posix_memalign/gnuradio-core/src/lib/missing/posix_memalign.cc
(rev 0)
+++
gnuradio/branches/developers/michaelld/posix_memalign/gnuradio-core/src/lib/missing/posix_memalign.cc
2008-09-21 14:59:48 UTC (rev 9630)
@@ -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 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 /* !HAVE_VALLOC */
+
+ /* no posix_memalign or valloc; no idea what to do. */
+
+#error gnuradio-core/src/libmissing/posix_memalign.c: Cannot find a way to
alloc aligned memory.
+
+#endif /* HAVE_VALLOC */
+
+ if (*memptr == 0)
+ return (ENOMEM);
+ else
+ return (0);
+};
+
+#endif /* ! HAVE_POSIX_MEMALIGN */
Modified:
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
2008-09-21 00:45:29 UTC (rev 9629)
+++
gnuradio/branches/developers/michaelld/posix_memalign/gnuradio-core/src/lib/missing/posix_memalign.h
2008-09-21 14:59:48 UTC (rev 9630)
@@ -27,16 +27,8 @@
#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_ */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r9630 - gnuradio/branches/developers/michaelld/posix_memalign/gnuradio-core/src/lib/missing,
michaelld <=