Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/librumpuser Fixes for Solarisa.
details: https://anonhg.NetBSD.org/src/rev/1b4b015c82eb
branches: trunk
changeset: 782752:1b4b015c82eb
user: pooka <pooka%NetBSD.org@localhost>
date: Sun Nov 18 19:29:40 2012 +0000
description:
Fixes for Solarisa.
diffstat:
lib/librumpuser/rumpuser.c | 25 +++++++++++++++---
lib/librumpuser/rumpuser_daemonize.c | 11 ++++++--
lib/librumpuser/rumpuser_port.h | 42 ++++++++++++++++++++++++++++---
lib/librumpuser/sp_common.c | 46 +++++++++++++++++++----------------
4 files changed, 90 insertions(+), 34 deletions(-)
diffs (truncated from 325 to 300 lines):
diff -r 0fc2167da1a2 -r 1b4b015c82eb lib/librumpuser/rumpuser.c
--- a/lib/librumpuser/rumpuser.c Sun Nov 18 19:25:25 2012 +0000
+++ b/lib/librumpuser/rumpuser.c Sun Nov 18 19:29:40 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rumpuser.c,v 1.22 2012/11/14 09:22:58 pooka Exp $ */
+/* $NetBSD: rumpuser.c,v 1.23 2012/11/18 19:29:40 pooka Exp $ */
/*
* Copyright (c) 2007-2010 Antti Kantee. All Rights Reserved.
@@ -28,7 +28,7 @@
#include "rumpuser_port.h"
#if !defined(lint)
-__RCSID("$NetBSD: rumpuser.c,v 1.22 2012/11/14 09:22:58 pooka Exp $");
+__RCSID("$NetBSD: rumpuser.c,v 1.23 2012/11/18 19:29:40 pooka Exp $");
#endif /* !lint */
#include <sys/ioctl.h>
@@ -46,9 +46,9 @@
#endif
#include <assert.h>
-#include <err.h>
#include <errno.h>
#include <fcntl.h>
+#include <netdb.h>
#include <poll.h>
#include <signal.h>
#include <stdarg.h>
@@ -291,6 +291,11 @@
}
}
+/* it's implicit */
+#if defined(__sun__) && !defined(MAP_FILE)
+#define MAP_FILE 0
+#endif
+
mmflags = MAP_FILE;
if (flags & RUMPUSER_FILEMMAP_SHARED)
mmflags |= MAP_SHARED;
@@ -343,7 +348,14 @@
#define TESTSET(_ru_, _h_) if (ruflags & _ru_) flags |= _h_;
TESTSET(RUMPUSER_OPEN_CREATE, O_CREAT);
TESTSET(RUMPUSER_OPEN_EXCL, O_EXCL);
+#ifdef O_DIRECT
TESTSET(RUMPUSER_OPEN_DIRECT, O_DIRECT);
+#else
+ if (ruflags & RUMPUSER_OPEN_DIRECT) {
+ *error = EOPNOTSUPP;
+ return -1;
+ }
+#endif
#undef TESTSET
DOCALL_KLOCK(int, (open(path, flags, 0644)));
@@ -535,10 +547,10 @@
char tmp[MAXHOSTNAMELEN];
if (gethostname(tmp, sizeof(tmp)) == -1) {
- snprintf(name, namelen, "rump-%05d.rumpdomain", getpid());
+ snprintf(name, namelen, "rump-%05d.rumpdomain", (int)getpid());
} else {
snprintf(name, namelen, "rump-%05d.%s.rumpdomain",
- getpid(), tmp);
+ (int)getpid(), tmp);
}
*error = 0;
@@ -743,6 +755,9 @@
free(line);
fclose(fp);
}
+#elif __sun__
+ /* XXX: this is just a rough estimate ... */
+ ncpu = sysconf(_SC_NPROCESSORS_ONLN);
#endif
return ncpu;
diff -r 0fc2167da1a2 -r 1b4b015c82eb lib/librumpuser/rumpuser_daemonize.c
--- a/lib/librumpuser/rumpuser_daemonize.c Sun Nov 18 19:25:25 2012 +0000
+++ b/lib/librumpuser/rumpuser_daemonize.c Sun Nov 18 19:29:40 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rumpuser_daemonize.c,v 1.3 2012/07/27 09:09:05 pooka Exp $ */
+/* $NetBSD: rumpuser_daemonize.c,v 1.4 2012/11/18 19:29:40 pooka Exp $ */
/*
* Copyright (c) 2010 Antti Kantee. All Rights Reserved.
@@ -28,7 +28,7 @@
#include "rumpuser_port.h"
#if !defined(lint)
-__RCSID("$NetBSD: rumpuser_daemonize.c,v 1.3 2012/07/27 09:09:05 pooka Exp $");
+__RCSID("$NetBSD: rumpuser_daemonize.c,v 1.4 2012/11/18 19:29:40 pooka Exp $");
#endif /* !lint */
#include <sys/types.h>
@@ -36,10 +36,15 @@
#include <errno.h>
#include <fcntl.h>
-#include <paths.h>
#include <stdio.h>
#include <unistd.h>
+#ifdef __sun__
+#define _PATH_DEVNULL "/dev/null"
+#else
+#include <paths.h>
+#endif
+
static int isdaemonizing;
static int daemonpipe[2];
diff -r 0fc2167da1a2 -r 1b4b015c82eb lib/librumpuser/rumpuser_port.h
--- a/lib/librumpuser/rumpuser_port.h Sun Nov 18 19:25:25 2012 +0000
+++ b/lib/librumpuser/rumpuser_port.h Sun Nov 18 19:29:40 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rumpuser_port.h,v 1.3 2012/09/03 11:33:35 pooka Exp $ */
+/* $NetBSD: rumpuser_port.h,v 1.4 2012/11/18 19:29:40 pooka Exp $ */
/*
* Portability header for non-NetBSD platforms.
@@ -15,6 +15,10 @@
#ifndef _LIB_LIBRUMPUSER_RUMPUSER_PORT_H_
#define _LIB_LIBRUMPUSER_RUMPUSER_PORT_H_
+#ifdef __sun__
+typedef long register_t;
+#endif
+
#ifdef __NetBSD__
#include <sys/cdefs.h>
#include <sys/param.h>
@@ -49,7 +53,7 @@
#include <sys/types.h>
#include <sys/param.h>
-#if defined(__linux__)
+#if defined(__linux__) || defined(__sun__)
#include <errno.h>
#include <stdlib.h>
#include <string.h>
@@ -74,6 +78,21 @@
}
#endif
+/* Solarisa 10 has memalign() but no posix_memalign() */
+#if defined(__sun__)
+#include <stdlib.h>
+
+static inline int
+posix_memalign(void **ptr, size_t align, size_t size)
+{
+
+ *ptr = memalign(align, size);
+ if (*ptr == NULL)
+ return ENOMEM;
+ return 0;
+}
+#endif /* __sun__ */
+
#ifndef __RCSID
#define __RCSID(a)
#endif
@@ -86,7 +105,7 @@
#define _DIAGASSERT(_p_)
#endif
-#ifdef __linux__
+#if defined(__linux__) || defined(__sun__)
#define SA_SETLEN(a,b)
#else /* BSD */
#define SA_SETLEN(_sa_, _len_) ((struct sockaddr *)_sa_)->sa_len = _len_
@@ -121,7 +140,7 @@
#define __UNCONST(_a_) ((void *)(unsigned long)(const void *)(_a_))
#endif
-#ifdef __linux__
+#if defined(__linux__) || defined(__sun__)
#define arc4random() random()
#endif
@@ -129,11 +148,24 @@
#define __NetBSD_Prereq__(a,b,c) 0
#endif
+#include <sys/socket.h>
+
#if !defined(__CMSG_ALIGN)
-#include <sys/socket.h>
#ifdef CMSG_ALIGN
#define __CMSG_ALIGN(a) CMSG_ALIGN(a)
#endif
#endif
+#ifndef PF_LOCAL
+#define PF_LOCAL PF_UNIX
+#endif
+#ifndef AF_LOCAL
+#define AF_LOCAL AF_UNIX
+#endif
+
+/* pfft, but what are you going to do? */
+#ifndef MSG_NOSIGNAL
+#define MSG_NOSIGNAL 0
+#endif
+
#endif /* _LIB_LIBRUMPUSER_RUMPUSER_PORT_H_ */
diff -r 0fc2167da1a2 -r 1b4b015c82eb lib/librumpuser/sp_common.c
--- a/lib/librumpuser/sp_common.c Sun Nov 18 19:25:25 2012 +0000
+++ b/lib/librumpuser/sp_common.c Sun Nov 18 19:29:40 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sp_common.c,v 1.33 2012/09/21 14:33:03 pooka Exp $ */
+/* $NetBSD: sp_common.c,v 1.34 2012/11/18 19:29:40 pooka Exp $ */
/*
* Copyright (c) 2010, 2011 Antti Kantee. All Rights Reserved.
@@ -86,8 +86,10 @@
#define host_setsockopt setsockopt
#endif
-#define IOVPUT(_io_, _b_) _io_.iov_base = &_b_; _io_.iov_len = sizeof(_b_);
-#define IOVPUT_WITHSIZE(_io_, _b_, _l_) _io_.iov_base = _b_; _io_.iov_len = _l_;
+#define IOVPUT(_io_, _b_) _io_.iov_base = \
+ (void *)&_b_; _io_.iov_len = sizeof(_b_);
+#define IOVPUT_WITHSIZE(_io_, _b_, _l_) _io_.iov_base = \
+ (void *)(_b_); _io_.iov_len = _l_;
#define SENDIOV(_spc_, _iov_) dosend(_spc_, _iov_, __arraycount(_iov_))
/*
@@ -346,7 +348,8 @@
_DIAGASSERT(n == 0);
break;
} else {
- iov[0].iov_base = (uint8_t *)iov[0].iov_base + n;
+ iov[0].iov_base =
+ (void *)((uint8_t *)iov[0].iov_base + n);
iov[0].iov_len -= n;
}
}
@@ -630,11 +633,11 @@
static int
unix_parse(const char *addr, struct sockaddr **sa, int allow_wildcard)
{
- struct sockaddr_un sun;
+ struct sockaddr_un s_un;
size_t slen;
int savepath = 0;
- if (strlen(addr) >= sizeof(sun.sun_path))
+ if (strlen(addr) >= sizeof(s_un.sun_path))
return ENAMETOOLONG;
/*
@@ -644,8 +647,8 @@
* one and the server does a chdir() between now than the
* cleanup.
*/
- memset(&sun, 0, sizeof(sun));
- sun.sun_family = AF_LOCAL;
+ memset(&s_un, 0, sizeof(s_un));
+ s_un.sun_family = AF_LOCAL;
if (*addr != '/') {
char mywd[PATH_MAX];
@@ -653,30 +656,31 @@
fprintf(stderr, "warning: cannot determine cwd, "
"omitting socket cleanup\n");
} else {
- if (strlen(addr)+strlen(mywd)+1 >= sizeof(sun.sun_path))
+ if (strlen(addr)+strlen(mywd)+1
+ >= sizeof(s_un.sun_path))
return ENAMETOOLONG;
- strcpy(sun.sun_path, mywd);
- strcat(sun.sun_path, "/");
+ strcpy(s_un.sun_path, mywd);
+ strcat(s_un.sun_path, "/");
savepath = 1;
}
}
- strcat(sun.sun_path, addr);
-#ifdef __linux__
- slen = sizeof(sun);
+ strcat(s_un.sun_path, addr);
+#if defined(__linux__) || defined(__sun__)
+ slen = sizeof(s_un);
#else
- sun.sun_len = SUN_LEN(&sun);
- slen = sun.sun_len+1; /* get the 0 too */
+ s_un.sun_len = SUN_LEN(&s_un);
+ slen = s_un.sun_len+1; /* get the 0 too */
#endif
if (savepath && *parsedurl == '\0') {
snprintf(parsedurl, sizeof(parsedurl),
- "unix://%s", sun.sun_path);
+ "unix://%s", s_un.sun_path);
}
Home |
Main Index |
Thread Index |
Old Index