Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Compile on NetBSD #1112

Closed
wants to merge 1 commit into from

9 participants

@amdg

I saw another pull request based on pkgsrc wip but it only cares about compiling on NetBSD. This patch is hopefully less intrusive on other platforms. Resulting binary runs example.js successfully on NetBSD 4.0.1 and 5.1.

Anna Gabutero Compile on NetBSD ba78ccd
@BooBSD

Great work!

@ry
ry commented

Are you sending the changes to V8 upstream?

@pquerna pquerna commented on the diff
src/platform_netbsd.cc
((3 lines not shown))
+
+#include <stdlib.h>
+#include <kvm.h>
+#include <sys/sched.h>
+#include <sys/sysctl.h>
+#include <paths.h>
+#include <fcntl.h>
+#include <string.h>
+#include <unistd.h>
+
+
+namespace node {
+
+using namespace v8;
+
+static char *process_title;
@pquerna Owner
pquerna added a note

change to
static char *process_title = NULL;

?

@ry
ry added a note

static global variables are guaranteed to be zeroed on program start. See ANSI-C spec http://flash-gordon.me.uk/ansi.c.txt section 3.5.7

If an object that has static storage duration is not initialized
explicitly, it is initialized implicitly as if every member that has
arithmetic type were assigned 0 and every member that has pointer type
were assigned a null pointer constant.  If an object that has
automatic storage duration is not initialized explicitly, its value is
indeterminate.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@rmustacc rmustacc commented on the diff
src/platform_netbsd.cc
((57 lines not shown))
+ *vsize = (kinfo->p_vm_tsize + kinfo->p_vm_dsize + kinfo->p_vm_ssize) * page_size;
+
+ kvm_close(kd);
+
+ return 0;
+
+error:
+ if (kd) kvm_close(kd);
+ return -1;
+}
+
+
+int Platform::GetExecutablePath(char* buffer, size_t* size) {
+ if (0 < (*size = readlink("/proc/curproc/file", buffer, sizeof(buffer)))) {
+ buffer[*size] = '\0';
+ return 0;
@rmustacc Owner

Hi, sizeof (buffer) isn't what you want to be using here, that would be the sizeof (char ). You want to use *size - 1 for the last argument. readlink(2) is defined to put as many bytes into the buffer as possible. However, if you do end up decrementing the size passed into readlink by one, then it is safe to do buffer[size] = '\0';. Otherwise you would be creating a buffer overflow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@japj

I think the patch needs to be split in several parts now
1) changes to c-ares and eio which now live as libuv dependencies. @ry do we have anyone working on libuv with netbsd?
2) v8 changes that should be filed upstream (has this been done yet?)
3) 'actual' node changes (these can land when the rest is in place?)

@msporleder

joyent/libuv#180

the v8 changes originate with OpenBSD so I'm letting them handle pushing it upstream.

@kivikakk

joyent/libuv#180 has been accepted—I wonder if we can work out what to do with this now?

@bnoordhuis

PR no longer applies, closing.

@bnoordhuis bnoordhuis closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 27, 2011
  1. Compile on NetBSD

    Anna Gabutero authored
Something went wrong with that request. Please try again.