Deal with |#if 0| code in mozalloc.h

RESOLVED FIXED

Status

()

--
enhancement
RESOLVED FIXED
9 years ago
9 years ago

People

(Reporter: sgautherie, Assigned: cjones)

Tracking

Trunk
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(URL)

Attachments

(1 attachment)

(Reporter)

Description

9 years ago
{
82 /* 
83  * If we don't have these system functions, but do have jemalloc
84  * replacements, go ahead and declare them independently of jemalloc.
85  * Trying to #include the jemalloc header causes redeclaration of some
86  * system functions with different visibility.
87  */
88 /* FIXME/cjones: make something like the following work with jemalloc */
89 #if 0
90 #if !defined(HAVE_POSIX_MEMALIGN) && defined(HAVE_JEMALLOC_POSIX_MEMALIGN)
91 MOZALLOC_IMPORT int posix_memalign(void **, size_t, size_t)
92     NS_WARN_UNUSED_RESULT;
93 #endif
94 #endif
}

NB: I noticed it because HAVE_JEMALLOC_POSIX_MEMALIGN is used here only.
(Hence c-c configure.in might not need it...)

Comment 1

9 years ago
Since early March 2010, FreeBSD builds of the central trunk fail as follows:

c++ -o mozalloc.o -c  -DOSTYPE=\"FreeBSD7\" -DOSARCH=FreeBSD  -I../../../memory/mozalloc -I. -I../../dist/include -I../../dist/include/nsprpub  -I/home/leighton/development/firefox/source/sctp/trunk/mozilla/obj-ff-dbg-no-sctp/dist/include/nspr -I/home/leighton/development/firefox/source/sctp/trunk/mozilla/obj-ff-dbg-no-sctp/dist/include/nss       -fPIC -I/usr/local/include -fno-rtti -fno-exceptions -Wall -Wpointer-arith -Woverloaded-virtual -Wsynth -Wno-ctor-dtor-privacy -Wno-non-virtual-dtor -Wcast-align -Wno-invalid-offsetof -Wno-variadic-macros -Werror=return-type -Wno-long-long -pedantic -fno-strict-aliasing -fshort-wchar -pipe  -DDEBUG -D_DEBUG -DDEBUG_leighton -DTRACING -g  -I/usr/local/include -DMOZILLA_CLIENT -include ../../mozilla-config.h -Wp,-MD,.deps/mozalloc.pp ../../../memory/mozalloc/mozalloc.cpp
../../../memory/mozalloc/mozalloc.cpp: In function 'void* moz_xvalloc(size_t)':
../../../memory/mozalloc/mozalloc.cpp:196: error: 'valloc' was not declared in this scope
../../../memory/mozalloc/mozalloc.cpp: In function 'void* moz_valloc(size_t)':
../../../memory/mozalloc/mozalloc.cpp:206: error: 'valloc' was not declared in this scope

A simple solution is to add

#if defined(XP_UNIX)
#include <unistd.h>
#endif

to mozalloc.cpp, but valloc has been obsoleted by posix_memalign on FreeBSD, so perhaps that's not the best way to go.

It looks like the fix for this bug will define HAVE_POSIX_MEMALIGN.  Will it also use posix_memalign to address the FreeBSD valloc problem, or should I file a separate bug report?
Interesting.  My |man valloc| on linux says it comes from <malloc.h>.  I'm OK with a patch that adds |#include <unistd.h>| (per http://www.unix.com/man-page/FreeBSD/3/valloc/).

Comment 3

9 years ago
Thanks.  Should I open a new bug report or should I post a patch to this bug?  I'm inclined to think I should open a new bug report since this doesn't quite seem to be the same issue being addressed here.
Sure, new bug is fine.
Created attachment 439349 [details] [diff] [review]
Wrap posix_memalign, memalign, and valloc if jemalloc provides them and the OS doesn't

The two r? requests are meant to be "either or".  Please let me know if there's another qualified reviewer with a shorter review queue.
Assignee: nobody → jones.chris.g
Attachment #439349 - Flags: review?(vladimir)
Attachment #439349 - Flags: review?(benjamin)

Updated

9 years ago
Attachment #439349 - Flags: review?(benjamin) → review+
Attachment #439349 - Flags: review?(vladimir)
http://hg.mozilla.org/mozilla-central/rev/97db872fb3b5
Status: NEW → RESOLVED
Last Resolved: 9 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.