Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190305205601.GA14026@port70.net>
Date: Tue, 5 Mar 2019 21:56:01 +0100
From: Szabolcs Nagy <nsz@...t70.net>
To: musl@...ts.openwall.com
Subject: Re: Asterisk 16 function redefines

* Markus Wichmann <nullplan@....net> [2019-03-05 21:05:30 +0100]:
> On Tue, Mar 05, 2019 at 08:28:50PM +0100, Sebastian Kemper wrote:
> > #define calloc(nmemb, size) \
> > 	__ast_repl_calloc(nmemb, size, __FILE__, __LINE__, __PRETTY_FUNCTION__)
> > #define malloc(size) \
> > 	__ast_repl_malloc(size, __FILE__, __LINE__, __PRETTY_FUNCTION__)
> > #define free(ptr) \
> > 	__ast_free(ptr, __FILE__, __LINE__, __PRETTY_FUNCTION__)
> > 
> > Compile output example:
> > 
> > /home/sk/tmp/openwrt/staging_dir/toolchain-mips_24kc_gcc-7.4.0_musl/include/sched.h:76:28: error: expected declaration specifiers or '...' before string constant
> >  void *calloc(size_t, size_t);
> >                             ^
> 
> Welcome to the wonderful world of the preprocessor. The define above is
> in effect here, so the compiler never sees the valid function prototype,
> the compiler sees
> 
> void *__ast_repl_calloc(size_t, size_t, "sched.h", 76, "");
> 
> And can't deal with that. Maybe they should include the replacements as
> the very last thing.

yeah that's one solution: don't include libc
headers after these macros (it may require
significant changes though, a quick workaround
hack is to preinclude sched.h before the
macros)

(in principle these names are reserved for the
implementation so such macros are not required
to work, in practice they work if there is no
later declaration of these functions.

normally stdlib.h declares these functions, so
if that's included before the macro definitions
then it works, however with _GNU_SOURCE defined
musl also declares calloc in sched.h.)

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.