timejson.c fails to compile on FreeBSD

Bug #1068328 reported by Jim Long
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenSRF
New
Undecided
Unassigned

Bug Description

timejson.c includes <malloc.h>. FreeBSD declares the prototypes for malloc(), et al in stdlib.h.

Patch attached.

Without the patch, the following behaviour is observed:

# uname -srp
FreeBSD 8.3-STABLE amd64
# pwd
/home/opensrf/OpenSRF
# autoreconf -i
...
# CFLAGS="-I/usr/local/include" LDFLAGS="-L/usr/local/lib" ./configure --prefix=/openils \
--sysconfdir=/openils/conf --with-apxs=/usr/local/sbin/apxs --with-libxml=/usr/local/include/libxml2 \
--with-includes=/usr/local/include
...
# gmake
...
In file included from timejson.c:8:
/usr/include/malloc.h:3:2: error: #error "<malloc.h> has been replaced by <stdlib.h>"
gmake[2]: *** [timejson.o] Error 1
gmake[2]: Leaving directory `/usr/home/opensrf/OpenSRF/src/c-apps'
gmake[1]: *** [all-recursive] Error 1
gmake[1]: Leaving directory `/usr/home/opensrf/OpenSRF/src'
gmake: *** [all-recursive] Error 1
# cat -n src/c-apps/timejson.c | head
     1 #include <stdlib.h>
     2 #include <stdio.h>
     3 #include <string.h>
     4 #include <stdarg.h>
     5 #include <time.h>
     6 #include <sys/time.h>
     7 #include <sys/resource.h>
     8 #include <malloc.h>
     9 #include "opensrf/utils.h"
    10 #include "opensrf/osrf_json.h"
#

Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

Signed-off-by:

Jim Long
<email address hidden>

Tags: bsd freebsd
Revision history for this message
Jim Long (evergreen-9) wrote :
Jim Long (evergreen-9)
description: updated
Revision history for this message
Jason Stephenson (jstephenson) wrote :

Jim,

I liked the patch that you sent me privately better, the one where you checked if __STDC__ was defined. Could you add that one to this bug as well?

Thanks,
Jason

Revision history for this message
Jim Long (evergreen-9) wrote :

That was not a patch, I was showing you the contents of FreeBSD's /usr/include/malloc.h.

malloc.h looks at whether __STDC__ is defined. If it is, it throws an error. If __STDC__ is not
defined, then malloc.h includes stdlib.h.

In either case, timejson.c already includes stdlib.h at line 1 before including malloc.h at line 8, so ....

/usr/include/malloc.h attached.

Holler again if I've misunderstood your request.

Jim

Revision history for this message
Bill Erickson (berick) wrote :
Revision history for this message
Jason Stephenson (jstephenson) wrote :

Bill, thanks for sharing. I think Jim has missed applying the above branch to OpenSRF. It is my fault since I neglected to mention it and even suggested that OpenSRF builds without patches, which was likely me misremembering.

I actually think that the inclusion of malloc.h can be removed from Linux, too. I've never needed to include it, unless I'm doing something implementation-specific that one shouldn't do in the first place.

Just my two bits.

Revision history for this message
Jason Stephenson (jstephenson) wrote :

Also, I am inclined to abandon the *bsd-compat branches at the moment in favor of a solution to https://bugs.launchpad.net/evergreen/+bug/968531

Updating our use of autotools would go a long way to smoothing the addition of new platforms.

Revision history for this message
Bill Erickson (berick) wrote : Re: [Bug 1068328] Re: timejson.c fails to compile on FreeBSD

On Fri, Oct 19, 2012 at 9:17 AM, Jason Stephenson <
<email address hidden>> wrote:

>
> I actually think that the inclusion of malloc.h can be removed from
> Linux, too. I've never needed to include it, unless I'm doing something
> implementation-specific that one shouldn't do in the first place.
>

Agreed. I guess I though the malloc_stats() stuff needed it, but that
doesn't appear to be the case.

-b

--
Bill Erickson
| Senior Software Developer
| phone: 877-OPEN-ILS (673-6457)
| email: <email address hidden>
| web: http://esilibrary.com
| Equinox Software, Inc. / Your Library's Guide to Open Source

Jim Long (evergreen-9)
description: updated
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

Bug watches keep track of this bug in other bug trackers.