all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#15094: Fix for posix_memalign on Cygwin
@ 2013-08-14 16:22 Ken Brown
  2013-08-14 19:11 ` Ken Brown
  0 siblings, 1 reply; 9+ messages in thread
From: Ken Brown @ 2013-08-14 16:22 UTC (permalink / raw)
  To: 15094

[-- Attachment #1: Type: text/plain, Size: 748 bytes --]

Cygwin allows applications to supply their own malloc but not, until 
today, their own posix_memalign.  This has caused problems with the GTK 
build of Emacs on Cygwin.  The problem became worse with the latest Glib 
update.  Anyone who wants the gory details can find them starting here:

   http://cygwin.com/ml/cygwin-xfree/2013-08/msg00018.html

Cygwin was just patched today to allow applications to supply their own 
posix_memalign (but not their own memalign), which solves the Glib 
problem.  But posix_memalign in gmalloc.c calls memalign, so I need to 
make sure that it calls Emacs's memalign.  The attached patch does this. 
  Is this a reasonable way to handle the problem?  (I plan to also add 
an explanatory comment.)

Thanks.

Ken

[-- Attachment #2: memalign.patch --]
[-- Type: text/plain, Size: 412 bytes --]

=== modified file 'src/gmalloc.c'
--- src/gmalloc.c	2013-01-02 16:13:04 +0000
+++ src/gmalloc.c	2013-08-14 16:01:02 +0000
@@ -1558,8 +1558,14 @@
 
 void *(*__memalign_hook) (size_t size, size_t alignment);
 
+#ifdef CYGWIN
+#define memalign memalign1
+void *
+memalign1 (size_t alignment, size_t size)
+#else
 void *
 memalign (size_t alignment, size_t size)
+#endif
 {
   void *result;
   size_t adj, lastadj;


^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#15094: Fix for posix_memalign on Cygwin
  2013-08-14 16:22 bug#15094: Fix for posix_memalign on Cygwin Ken Brown
@ 2013-08-14 19:11 ` Ken Brown
  2013-08-14 19:29   ` Eli Zaretskii
  0 siblings, 1 reply; 9+ messages in thread
From: Ken Brown @ 2013-08-14 19:11 UTC (permalink / raw)
  To: 15094-done

On 8/14/2013 12:22 PM, Ken Brown wrote:
> Cygwin allows applications to supply their own malloc but not, until
> today, their own posix_memalign.  This has caused problems with the GTK
> build of Emacs on Cygwin.  The problem became worse with the latest Glib
> update.  Anyone who wants the gory details can find them starting here:
>
>    http://cygwin.com/ml/cygwin-xfree/2013-08/msg00018.html
>
> Cygwin was just patched today to allow applications to supply their own
> posix_memalign (but not their own memalign), which solves the Glib
> problem.  But posix_memalign in gmalloc.c calls memalign, so I need to
> make sure that it calls Emacs's memalign.  The attached patch does this.
>   Is this a reasonable way to handle the problem?  (I plan to also add
> an explanatory comment.)

I made this more complicated than necessary.  I've installed a simpler 
version as bzr revision 113880, and I'm closing the bug.

Ken






^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#15094: Fix for posix_memalign on Cygwin
  2013-08-14 19:11 ` Ken Brown
@ 2013-08-14 19:29   ` Eli Zaretskii
  2013-08-14 19:52     ` Ken Brown
  0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2013-08-14 19:29 UTC (permalink / raw)
  To: Ken Brown; +Cc: 15094

> Date: Wed, 14 Aug 2013 15:11:09 -0400
> From: Ken Brown <kbrown@cornell.edu>
> 
> On 8/14/2013 12:22 PM, Ken Brown wrote:
> > Cygwin allows applications to supply their own malloc but not, until
> > today, their own posix_memalign.  This has caused problems with the GTK
> > build of Emacs on Cygwin.  The problem became worse with the latest Glib
> > update.  Anyone who wants the gory details can find them starting here:
> >
> >    http://cygwin.com/ml/cygwin-xfree/2013-08/msg00018.html
> >
> > Cygwin was just patched today to allow applications to supply their own
> > posix_memalign (but not their own memalign), which solves the Glib
> > problem.  But posix_memalign in gmalloc.c calls memalign, so I need to
> > make sure that it calls Emacs's memalign.  The attached patch does this.
> >   Is this a reasonable way to handle the problem?  (I plan to also add
> > an explanatory comment.)
> 
> I made this more complicated than necessary.  I've installed a simpler 
> version as bzr revision 113880, and I'm closing the bug.

Thanks, but could you please make the commentary more clear?  I'm
afraid it doesn't make sense to me: if posix_memalign calls memalign,
then why does the latter have to be renamed, if all you want is for it
to be called?  Why won't it be called unless renamed?

TIA





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#15094: Fix for posix_memalign on Cygwin
  2013-08-14 19:29   ` Eli Zaretskii
@ 2013-08-14 19:52     ` Ken Brown
  2013-08-15  2:46       ` Eli Zaretskii
  0 siblings, 1 reply; 9+ messages in thread
From: Ken Brown @ 2013-08-14 19:52 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 15094

On 8/14/2013 3:29 PM, Eli Zaretskii wrote:
> Thanks, but could you please make the commentary more clear?  I'm
> afraid it doesn't make sense to me: if posix_memalign calls memalign,
> then why does the latter have to be renamed, if all you want is for it
> to be called?  Why won't it be called unless renamed?

How's this:

/* Cygwin allows applications to provide their own malloc.  As of
cygwin-1.7.24, applications that provide their own malloc are also
allowed to provide their own posix_memalign (but not memalign).  Calls
to memalign are handled by Cygwin's memalign, which always returns
ENOSYS if the application has defined its own malloc.  So we have to
rename memalign in order to make sure that posix_memalign calls
Emacs's memalign rather than Cygwin's.  */

Ken





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#15094: Fix for posix_memalign on Cygwin
  2013-08-14 19:52     ` Ken Brown
@ 2013-08-15  2:46       ` Eli Zaretskii
  2013-08-15 11:51         ` Ken Brown
  0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2013-08-15  2:46 UTC (permalink / raw)
  To: Ken Brown; +Cc: 15094

> Date: Wed, 14 Aug 2013 15:52:53 -0400
> From: Ken Brown <kbrown@cornell.edu>
> CC: 15094@debbugs.gnu.org
> 
> /* Cygwin allows applications to provide their own malloc.  As of
> cygwin-1.7.24, applications that provide their own malloc are also
> allowed to provide their own posix_memalign (but not memalign).  Calls
> to memalign are handled by Cygwin's memalign, which always returns
> ENOSYS if the application has defined its own malloc.  So we have to
> rename memalign in order to make sure that posix_memalign calls
> Emacs's memalign rather than Cygwin's.  */

How does Cygwin memalign come into play, when Emacs provides its own?





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#15094: Fix for posix_memalign on Cygwin
  2013-08-15  2:46       ` Eli Zaretskii
@ 2013-08-15 11:51         ` Ken Brown
  2013-08-15 13:00           ` Ken Brown
  0 siblings, 1 reply; 9+ messages in thread
From: Ken Brown @ 2013-08-15 11:51 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 15094

On 8/14/2013 10:46 PM, Eli Zaretskii wrote:
>> Date: Wed, 14 Aug 2013 15:52:53 -0400
>> From: Ken Brown <kbrown@cornell.edu>
>> CC: 15094@debbugs.gnu.org
>>
>> /* Cygwin allows applications to provide their own malloc.  As of
>> cygwin-1.7.24, applications that provide their own malloc are also
>> allowed to provide their own posix_memalign (but not memalign).  Calls
>> to memalign are handled by Cygwin's memalign, which always returns
>> ENOSYS if the application has defined its own malloc.  So we have to
>> rename memalign in order to make sure that posix_memalign calls
>> Emacs's memalign rather than Cygwin's.  */
>
> How does Cygwin memalign come into play, when Emacs provides its own?

As I said in the comment, Cygwin does not let applications define their 
own memalign.  During linking, calls to memalign become calls to 
Cygwin's memalign.

Ken





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#15094: Fix for posix_memalign on Cygwin
  2013-08-15 11:51         ` Ken Brown
@ 2013-08-15 13:00           ` Ken Brown
  2013-08-15 16:15             ` Ken Brown
  0 siblings, 1 reply; 9+ messages in thread
From: Ken Brown @ 2013-08-15 13:00 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 15094

On 8/15/2013 7:51 AM, Ken Brown wrote:
> On 8/14/2013 10:46 PM, Eli Zaretskii wrote:
>>> Date: Wed, 14 Aug 2013 15:52:53 -0400
>>> From: Ken Brown <kbrown@cornell.edu>
>>> CC: 15094@debbugs.gnu.org
>>>
>>> /* Cygwin allows applications to provide their own malloc.  As of
>>> cygwin-1.7.24, applications that provide their own malloc are also
>>> allowed to provide their own posix_memalign (but not memalign).  Calls
>>> to memalign are handled by Cygwin's memalign, which always returns
>>> ENOSYS if the application has defined its own malloc.  So we have to
>>> rename memalign in order to make sure that posix_memalign calls
>>> Emacs's memalign rather than Cygwin's.  */
>>
>> How does Cygwin memalign come into play, when Emacs provides its own?
>
> As I said in the comment, Cygwin does not let applications define their
> own memalign.  During linking, calls to memalign become calls to
> Cygwin's memalign.

Hold on...I think I'm missing something obvious.  I have to recheck this.

Ken





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#15094: Fix for posix_memalign on Cygwin
  2013-08-15 13:00           ` Ken Brown
@ 2013-08-15 16:15             ` Ken Brown
  2013-08-15 16:39               ` Eli Zaretskii
  0 siblings, 1 reply; 9+ messages in thread
From: Ken Brown @ 2013-08-15 16:15 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 15094

On 8/15/2013 9:00 AM, Ken Brown wrote:
> On 8/15/2013 7:51 AM, Ken Brown wrote:
>> On 8/14/2013 10:46 PM, Eli Zaretskii wrote:
>>>> Date: Wed, 14 Aug 2013 15:52:53 -0400
>>>> From: Ken Brown <kbrown@cornell.edu>
>>>> CC: 15094@debbugs.gnu.org
>>>>
>>>> /* Cygwin allows applications to provide their own malloc.  As of
>>>> cygwin-1.7.24, applications that provide their own malloc are also
>>>> allowed to provide their own posix_memalign (but not memalign).  Calls
>>>> to memalign are handled by Cygwin's memalign, which always returns
>>>> ENOSYS if the application has defined its own malloc.  So we have to
>>>> rename memalign in order to make sure that posix_memalign calls
>>>> Emacs's memalign rather than Cygwin's.  */
>>>
>>> How does Cygwin memalign come into play, when Emacs provides its own?
>>
>> As I said in the comment, Cygwin does not let applications define their
>> own memalign.  During linking, calls to memalign become calls to
>> Cygwin's memalign.
>
> Hold on...I think I'm missing something obvious.  I have to recheck this.

Thanks for pressing me on this, Eli.  I did of course miss the obvious 
fact that posix_memalign in gmalloc.c will use memalign as defined in 
the same file.  I'll revert the change.  I'll also use the opportunity 
to update some comments elsewhere in the code.

Sorry for the noise.

Ken






^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#15094: Fix for posix_memalign on Cygwin
  2013-08-15 16:15             ` Ken Brown
@ 2013-08-15 16:39               ` Eli Zaretskii
  0 siblings, 0 replies; 9+ messages in thread
From: Eli Zaretskii @ 2013-08-15 16:39 UTC (permalink / raw)
  To: Ken Brown; +Cc: 15094

> Date: Thu, 15 Aug 2013 12:15:49 -0400
> From: Ken Brown <kbrown@cornell.edu>
> CC: 15094@debbugs.gnu.org
> 
> Thanks for pressing me on this, Eli.  I did of course miss the obvious 
> fact that posix_memalign in gmalloc.c will use memalign as defined in 
> the same file.  I'll revert the change.  I'll also use the opportunity 
> to update some comments elsewhere in the code.

Thanks.

> Sorry for the noise.

No need to apologize: no harm was done.





^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2013-08-15 16:39 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-14 16:22 bug#15094: Fix for posix_memalign on Cygwin Ken Brown
2013-08-14 19:11 ` Ken Brown
2013-08-14 19:29   ` Eli Zaretskii
2013-08-14 19:52     ` Ken Brown
2013-08-15  2:46       ` Eli Zaretskii
2013-08-15 11:51         ` Ken Brown
2013-08-15 13:00           ` Ken Brown
2013-08-15 16:15             ` Ken Brown
2013-08-15 16:39               ` Eli Zaretskii

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.