Subject: pkg/37131: 2 problems: i) NetBSD-current doesn't build because of signature of mremap(2) ii) os_mon driver doesn't build on NetBSD
To: None <pkg-manager@netbsd.org, gnats-admin@netbsd.org,>
From: None <nbsd@hck.sk>
List: pkgsrc-bugs
Date: 10/14/2007 16:00:02
>Number: 37131
>Category: pkg
>Synopsis: 2 problems: i) NetBSD-current doesn't build because of signature of mremap(2) ii) os_mon driver doesn't build on NetBSD
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: pkg-manager
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun Oct 14 16:00:00 +0000 2007
>Originator: Juraj Hercek
>Release: -current
>Organization:
>Environment:
NetBSD pkgsrc.hck.sk 4.99.31 NetBSD 4.99.31 (PKGSRC) #0: Sat Sep 29 11:35:18 CEST 2007 juraj@core:/netbsd/obj/sys/arch/i386/compile/PKGSRC i386
>Description:
There are 2 problems:
1) mremap(2) signature in NetBSD-current is different from the one used in other OSes. This prevents erlang to be built because of compile error when compiling erts/emulator/sys/common/erl_mseg.c file
2) os_mon in lib/os_mon doesn't get built because memsup.c file tries to include vm/vm_param.h file which doesn't exist on NetBSD-current. Since the os_mon doesn't build, it is not installed, but still listed in PLIST.
NOTE: The above applies most probably to latest NetBSD-4.0 rc candidate as well.
>How-To-Repeat:
Try to build the system on NetBSD-current and i) wait for compile error, when you fix signature of the mremap(), continue in build and see the problem of missing os_mon stuff when building binary package.
>Fix:
Following 2 patches allowed me to build erlang on current NetBSD:
<patch-af>
$NetBSD$
The NetBSD got a mremap(2) function implemetation on 2007-07-17, however the
signature of the mremap(2) function differs from the one used in other systems.
This patch allows usage of the mremap(2) on current NetBSD.
--- erts/emulator/sys/common/erl_mseg.c.orig 2007-04-16 12:22:46.000000000 +0000
+++ erts/emulator/sys/common/erl_mseg.c
@@ -369,10 +369,18 @@ mseg_recreate(void *old_seg, Uint old_si
#if defined(ERTS_MSEG_FAKE_SEGMENTS)
new_seg = erts_sys_realloc(ERTS_ALC_N_INVALID, NULL, old_seg, new_size);
#elif HAVE_MREMAP
+#if defined(__NetBSD__)
+ new_seg = (void *) mremap((void *) old_seg,
+ (size_t) old_size,
+ (void *) old_seg,
+ (size_t) new_size,
+ 0);
+#else
new_seg = (void *) mremap((void *) old_seg,
(size_t) old_size,
(size_t) new_size,
MREMAP_MAYMOVE);
+#endif
if (new_seg == (void *) MAP_FAILED)
new_seg = NULL;
#else
</patch-af>
<patch-ag>
$NetBSD$
NetBSD doesn't have vm/vm_param.h file and including it ends in compiler error.
This patch allows building erlang's os_mon on NetBSD.
--- lib/os_mon/c_src/memsup.c.orig 2007-10-14 12:45:03.000000000 +0000
+++ lib/os_mon/c_src/memsup.c
@@ -98,7 +98,7 @@
#ifdef BSD4_4
#include <sys/types.h>
#include <sys/sysctl.h>
-#ifndef __OpenBSD__
+#if !defined(__OpenBSD__) && !defined(__NetBSD__)
#include <vm/vm_param.h>
#endif
#if defined(__FreeBSD__) || defined(__DragonFly__)
</patch-ag>
After adding patch files to patches directory, recreate distinfo file with "make mdi".