Re: [Discuss-gnuradio] Re: [Commit-gnuradio] r10410 -gnuradio/trunk/gnuradio-core/src/lib/missing

2009-02-11 Thread Don Ward


Michael Dickens wrote:



On Feb 10, 2009, at 11:17 AM, Don Ward wrote:

As far as I can tell, MinGW has no standard aligned-memory
allocation functions. Can we use malloc16.c (in gnuradio-core/.../
general) or something like gcell/lib/runtime/gc_aligned_alloc.cc
instead?


malloc16.c requires the use of both the specific allocating
(malloc16Align () and calloc16Align ()) and freeing (free16Align ())
routines to do what it does, but it would work (even though it might
waste a bit of memory when allocating, in order to guarantee both
alignment as well as a means for storing the actual allocated pointer
value) ... This could be an option for certain issues.

gc_aligned_alloc () uses posix_memalign (), so that's not an option.

A better solution makes use of some built-in memory-alloc-with-
alignment function and uses the standard free () to dealloc.  That's
what the posix_memalign () function is meant to, and currently does,
provide.


Agreed, but as far as I can tell, Windows does not have an aligned memory 
allocation function that works with free() so this solution is not 
available.



The best way to do this would be to add on to the posix_memalign.cc
file for the specific OS and how it does allocating.  Use the
AC_CHECK_HEADER macro to check for the correct headers, then
AC_CHECK_FUNCS to make sure the functions exist and are callable.
Then #ifdef around the appropriate functions after the end of
HAVE_VALLOC in posix_memalign.cc for how this OS does it.


How about a test to automatically disable components that require 
posix_memalign during configuration?


Thanks,

-- Don W.



___
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
http://lists.gnu.org/mailman/listinfo/discuss-gnuradio


[Discuss-gnuradio] Re: [Commit-gnuradio] r10410 - gnuradio/trunk/gnuradio-core/src/lib/missing

2009-02-10 Thread Michael Dickens

Fix missing header include (Don Ward)

Modified: gnuradio/trunk/gnuradio-core/src/lib/missing/ 
posix_memalign.cc

===
#include posix_memalign.h
+#include malloc.h


This change breaks compile on OSX ... malloc.h is in /usr/include/ 
malloc/ on OSX, and is not needed on OSX or LINUX to be best of my  
knowledge for this code to compile ... only for the Windows  
environment.  Here's my suggested patch ... does no harm on Linux,  
takes care of the issue on Windows, and allows OSX to compile:


Index: configure.ac
===
--- configure.ac(revision 10414)
+++ configure.ac(working copy)
@@ -127,7 +127,7 @@
 AC_CHECK_HEADERS(linux/ppdev.h dev/ppbus/ppi.h sys/mman.h sys/ 
select.h sys/types.h)
 AC_CHECK_HEADERS(sys/resource.h stdint.h sched.h signal.h sys/ 
syscall.h)

 AC_CHECK_HEADERS(netinet/in.h)
-AC_CHECK_HEADERS(windows.h)
+AC_CHECK_HEADERS(windows.h malloc.h)
 AC_CHECK_HEADERS(vec_types.h)

 dnl Checks for typedefs, structures, and compiler characteristics.
Index: gnuradio-core/src/lib/missing/posix_memalign.cc
===
--- gnuradio-core/src/lib/missing/posix_memalign.cc (revision 10414)
+++ gnuradio-core/src/lib/missing/posix_memalign.cc (working copy)
@@ -25,7 +25,10 @@
 #endif

 #include posix_memalign.h
+
+#ifdef HAVE_MALLOC_H
 #include malloc.h
+#endif

 #ifndef HAVE_POSIX_MEMALIGN




___
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
http://lists.gnu.org/mailman/listinfo/discuss-gnuradio


Re: [Discuss-gnuradio] Re: [Commit-gnuradio] r10410 - gnuradio/trunk/gnuradio-core/src/lib/missing

2009-02-10 Thread Johnathan Corgan
On Tue, Feb 10, 2009 at 6:09 AM, Michael Dickens m...@alum.mit.edu wrote:

 This change breaks compile on OSX ... malloc.h is in /usr/include/malloc/ on
 OSX, and is not needed on OSX or LINUX to be best of my knowledge for this
 code to compile ... only for the Windows environment.  Here's my suggested
 patch ... does no harm on Linux, takes care of the issue on Windows, and
 allows OSX to compile:

Can you try changing the include to stdlib.h to see if that works on OSX?

Johnathan


___
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
http://lists.gnu.org/mailman/listinfo/discuss-gnuradio


Re: [Discuss-gnuradio] Re: [Commit-gnuradio] r10410 - gnuradio/trunk/gnuradio-core/src/lib/missing

2009-02-10 Thread Michael Dickens
Yes, that works on OSX 10.5, and should be backwards compatible to  
10.4 since /usr/include/stdlib.h exists on both OSs. - MLD


On Feb 10, 2009, at 9:24 AM, Johnathan Corgan wrote:
Can you try changing the include to stdlib.h to see if that works on  
OSX?




___
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
http://lists.gnu.org/mailman/listinfo/discuss-gnuradio


Re: [Discuss-gnuradio] Re: [Commit-gnuradio] r10410 -gnuradio/trunk/gnuradio-core/src/lib/missing

2009-02-10 Thread Don Ward

Michael Dickens wrote:


Fix missing header include (Don Ward)

Modified: gnuradio/trunk/gnuradio-core/src/lib/missing/
posix_memalign.cc
===
#include posix_memalign.h
+#include malloc.h


This change breaks compile on OSX ... malloc.h is in /usr/include/
malloc/ on OSX, and is not needed on OSX or LINUX to be best of my
knowledge for this code to compile ... only for the Windows
environment.  Here's my suggested patch ... does no harm on Linux,
takes care of the issue on Windows, and allows OSX to compile:


Oops, this is my mistake. I should have seen that valloc() is supposed to be 
in stdlib.h (but isn't there in Cygwin).  Thanks for fixing this.


I'm worried, though, that valloc isn't available at all on MinGW.  Is there 
another way to accomplish what is needed?


-- Don W.


Index: configure.ac
===
--- configure.ac (revision 10414)
+++ configure.ac (working copy)
@@ -127,7 +127,7 @@
 AC_CHECK_HEADERS(linux/ppdev.h dev/ppbus/ppi.h sys/mman.h sys/
select.h sys/types.h)
 AC_CHECK_HEADERS(sys/resource.h stdint.h sched.h signal.h sys/
syscall.h)
 AC_CHECK_HEADERS(netinet/in.h)
-AC_CHECK_HEADERS(windows.h)
+AC_CHECK_HEADERS(windows.h malloc.h)
 AC_CHECK_HEADERS(vec_types.h)

 dnl Checks for typedefs, structures, and compiler characteristics.
Index: gnuradio-core/src/lib/missing/posix_memalign.cc
===
--- gnuradio-core/src/lib/missing/posix_memalign.cc (revision 10414)
+++ gnuradio-core/src/lib/missing/posix_memalign.cc (working copy)
@@ -25,7 +25,10 @@
 #endif

 #include posix_memalign.h
+
+#ifdef HAVE_MALLOC_H
 #include malloc.h
+#endif

 #ifndef HAVE_POSIX_MEMALIGN




___
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
http://lists.gnu.org/mailman/listinfo/discuss-gnuradio







No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 8.0.233 / Virus Database: 270.10.20/1943 - Release Date: 02/07/09 
13:39:00




___
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
http://lists.gnu.org/mailman/listinfo/discuss-gnuradio


Re: [Discuss-gnuradio] Re: [Commit-gnuradio] r10410 -gnuradio/trunk/gnuradio-core/src/lib/missing

2009-02-10 Thread Michael Dickens

On Feb 10, 2009, at 10:11 AM, Don Ward wrote:
Oops, this is my mistake. I should have seen that valloc() is  
supposed to be in stdlib.h (but isn't there in Cygwin).  Thanks  
for fixing this.


I'm worried, though, that valloc isn't available at all on MinGW.   
Is there another way to accomplish what is needed?



The standard way of dealing with most #include's is to have AC check  
them in configure.ac to see if they exist (e.g.,  
AC_CHECK_HEADERS(malloc.h malloc/malloc.h stdlib.h)) then #ifdef  
around the #include to make it safe (e.g.:


#ifdef HAVE_STDLIB_H
#include stdlib.h
#endif

). With enough of these, one can usually find the correct header files  
and routines for a given OS.  If more than a few of these are required  
to find a given header / routine, then the user's code will generally  
be cleaner if all of this is moved to a common local header file which  
is then #include'd (e.g., as done for the posix_memalign () function).


Do you know what MinGW requires to get posix_memalign.cc to compile  
and be usable? - MLD



___
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
http://lists.gnu.org/mailman/listinfo/discuss-gnuradio


Re: [Discuss-gnuradio] Re: [Commit-gnuradio] r10410 -gnuradio/trunk/gnuradio-core/src/lib/missing

2009-02-10 Thread Don Ward


- Original Message - 
From: Michael Dickens m...@alum.mit.edu

To: Don Ward don2387w...@sprynet.com
Cc: GNU Radio Discussion discuss-gnuradio@gnu.org
Sent: Tuesday, February 10, 2009 10:32 AM
Subject: Re: [Discuss-gnuradio] Re: [Commit-gnuradio] 
r10410 -gnuradio/trunk/gnuradio-core/src/lib/missing




On Feb 10, 2009, at 10:11 AM, Don Ward wrote:

Oops, this is my mistake. I should have seen that valloc() is
supposed to be in stdlib.h (but isn't there in Cygwin).  Thanks
for fixing this.

I'm worried, though, that valloc isn't available at all on MinGW.
Is there another way to accomplish what is needed?



The standard way of dealing with most #include's is to have AC check
them in configure.ac to see if they exist (e.g.,
AC_CHECK_HEADERS(malloc.h malloc/malloc.h stdlib.h)) then #ifdef
around the #include to make it safe (e.g.:

#ifdef HAVE_STDLIB_H
#include stdlib.h
#endif

). With enough of these, one can usually find the correct header files
and routines for a given OS.  If more than a few of these are required
to find a given header / routine, then the user's code will generally
be cleaner if all of this is moved to a common local header file which
is then #include'd (e.g., as done for the posix_memalign () function).

Do you know what MinGW requires to get posix_memalign.cc to compile
and be usable? - MLD


As far as I can tell, MinGW has no standard aligned-memory allocation 
functions. Can we use malloc16.c (in gnuradio-core/.../general) or something 
like gcell/lib/runtime/gc_aligned_alloc.cc instead?

-- Don W.





___
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
http://lists.gnu.org/mailman/listinfo/discuss-gnuradio


Re: [Discuss-gnuradio] Re: [Commit-gnuradio] r10410 -gnuradio/trunk/gnuradio-core/src/lib/missing

2009-02-10 Thread Michael Dickens

On Feb 10, 2009, at 11:17 AM, Don Ward wrote:
As far as I can tell, MinGW has no standard aligned-memory  
allocation functions. Can we use malloc16.c (in gnuradio-core/.../ 
general) or something like gcell/lib/runtime/gc_aligned_alloc.cc  
instead?


malloc16.c requires the use of both the specific allocating  
(malloc16Align () and calloc16Align ()) and freeing (free16Align ())  
routines to do what it does, but it would work (even though it might  
waste a bit of memory when allocating, in order to guarantee both  
alignment as well as a means for storing the actual allocated pointer  
value) ... This could be an option for certain issues.


gc_aligned_alloc () uses posix_memalign (), so that's not an option.

A better solution makes use of some built-in memory-alloc-with- 
alignment function and uses the standard free () to dealloc.  That's  
what the posix_memalign () function is meant to, and currently does,  
provide.


The best way to do this would be to add on to the posix_memalign.cc  
file for the specific OS and how it does allocating.  Use the  
AC_CHECK_HEADER macro to check for the correct headers, then  
AC_CHECK_FUNCS to make sure the functions exist and are callable.   
Then #ifdef around the appropriate functions after the end of  
HAVE_VALLOC in posix_memalign.cc for how this OS does it.


As I don't have MinGW installed, I can't be of more use than these  
general recommendations.  Hope they help! - MLD



___
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
http://lists.gnu.org/mailman/listinfo/discuss-gnuradio