[beast/win32: 5/44] Applied 005_beast_sfi.diff: make sfi code compile.
- From: Stefan Westerfeld <stw src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [beast/win32: 5/44] Applied 005_beast_sfi.diff: make sfi code compile.
- Date: Fri, 29 Jan 2010 16:21:50 +0000 (UTC)
commit 2bda1f1bbc2a8a97e2a4ebd63f64fe1518b946ab
Author: Stefan Westerfeld <stefan space twc de>
Date: Fri Aug 28 09:04:40 2009 +0200
Applied 005_beast_sfi.diff: make sfi code compile.
sfi/sficomport.c | 23 +++++++++++++++++++++++
sfi/sficomwire.c | 25 ++++++++++++++++++++++++-
sfi/sfifilecrawler.c | 4 +++-
sfi/sfistore.c | 2 +-
sfi/sfitime.c | 2 +-
sfi/sfiwrapper.cc | 19 +++++++++++++++++++
sfi/sfiwrapper.h | 6 ++++++
7 files changed, 77 insertions(+), 4 deletions(-)
---
diff --git a/sfi/sficomport.c b/sfi/sficomport.c
index f65ff59..0d28d24 100644
--- a/sfi/sficomport.c
+++ b/sfi/sficomport.c
@@ -26,7 +26,9 @@
#include <fcntl.h>
#include <sys/time.h>
#include <sys/types.h>
+#ifndef WIN32
#include <sys/wait.h>
+#endif
static SFI_MSG_TYPE_DEFINE (debug_comport, "comport", SFI_MSG_DEBUG, NULL);
#define DEBUG(...) sfi_debug (debug_comport, __VA_ARGS__)
@@ -52,6 +54,10 @@ static SFI_MSG_TYPE_DEFINE (debug_comport, "comport", SFI_MSG_DEBUG, NULL);
static gint
nonblock_fd (gint fd)
{
+#ifdef WIN32
+ g_print ("WIN32: implement nonblock_fd");
+ return fd;
+#else
if (fd >= 0)
{
glong r, d_long;
@@ -66,6 +72,7 @@ nonblock_fd (gint fd)
while (r < 0 && errno == EINTR);
}
return fd;
+#endif
}
SfiComPort*
@@ -200,6 +207,9 @@ com_port_try_reap (SfiComPort *port,
{
if (port->remote_pid && !port->reaped)
{
+#ifdef WIN32
+ g_print ("implement com_port_try_reap\n");
+#else
int status = 0;
gint ret = waitpid (port->remote_pid, &status, mayblock ? 0 : WNOHANG);
if (ret > 0)
@@ -215,6 +225,7 @@ com_port_try_reap (SfiComPort *port,
}
else if (ret < 0 && errno == EINTR && mayblock)
com_port_try_reap (port, mayblock);
+#endif
}
}
@@ -243,8 +254,12 @@ sfi_com_port_close_remote (SfiComPort *port,
!port->reaped &&
!port->sigterm_sent)
{
+#ifdef WIN32
+ g_print ("WIN32: do implement kill()");
+#else
if (kill (port->remote_pid, SIGTERM) >= 0)
port->sigterm_sent = TRUE;
+#endif
com_port_try_reap (port, FALSE);
}
if (port->link)
@@ -603,6 +618,9 @@ sfi_com_port_recv_intern (SfiComPort *port,
if (blocking && !port->rvalues && port->pfd[0].fd >= 0)
{
+#ifdef WIN32
+ g_print ("WIN32: do implement select()\n");
+#else
struct timeval tv = { 60, 0, };
fd_set in_fds, out_fds, exp_fds;
gint xfd;
@@ -625,6 +643,7 @@ sfi_com_port_recv_intern (SfiComPort *port,
/* block only once so higher layers may handle signals */
blocking = FALSE;
goto loop_blocking;
+#endif
}
}
MASS_DEBUG ("[%s: DONE receiving]", port->ident);
@@ -730,8 +749,12 @@ sfi_com_port_reap_child (SfiComPort *port,
!port->reaped &&
!port->sigkill_sent)
{
+#ifdef WIN32
+ g_print ("WIN32: do implement kill\n");
+#else
if (kill (port->remote_pid, SIGKILL) >= 0)
port->sigkill_sent = TRUE;
+#endif
}
com_port_try_reap (port, TRUE);
}
diff --git a/sfi/sficomwire.c b/sfi/sficomwire.c
index 6e908d1..3388a12 100644
--- a/sfi/sficomwire.c
+++ b/sfi/sficomwire.c
@@ -23,7 +23,9 @@
#include <signal.h>
#include <fcntl.h>
#include <sys/time.h>
+#ifndef WIN32
#include <sys/resource.h>
+#endif
/* --- prototypes --- */
@@ -35,6 +37,7 @@ static GList* wire_find_link (GList *list,
static void
nonblock_fd (gint fd)
{
+#ifndef WIN32
if (fd >= 0)
{
glong r, d_long;
@@ -48,6 +51,7 @@ nonblock_fd (gint fd)
r = fcntl (fd, F_SETFL, d_long);
while (r < 0 && errno == EINTR);
}
+#endif
}
SfiComWire*
@@ -774,8 +778,10 @@ sfi_com_wire_close_remote (SfiComWire *wire,
if (wire->standard_error >= 0)
close (wire->standard_error);
wire->standard_error = -1;
+#ifndef WIN32
if (wire->remote_pid > 1 && terminate)
kill (wire->remote_pid, SIGTERM);
+#endif
wire->remote_pid = -1;
}
@@ -828,6 +834,9 @@ void
sfi_com_wire_select (SfiComWire *wire,
guint timeout)
{
+#ifdef WIN32
+ g_print ("WIN32: implement sfi_com_wire_select");
+#else
fd_set rfds, wfds, efds;
guint *fds, i, n, max_fd = 0;
struct timeval tv;
@@ -859,6 +868,7 @@ sfi_com_wire_select (SfiComWire *wire,
tv.tv_usec = (timeout % 1000) * 1000;
tv.tv_sec = timeout / 1000;
select (max_fd + 1, &rfds, &wfds, NULL, &tv);
+#endif
}
gchar*
@@ -919,11 +929,15 @@ sfi_com_set_spawn_dir (const gchar *cwd)
static void
unset_cloexec (gint fd)
{
+#ifdef WIN32
+ g_print ("WIN32: implement unset_cloexec\n");
+#else
gint r;
do
r = fcntl (fd, F_SETFD, 0 /* FD_CLOEXEC */);
while (r < 0 && errno == EINTR);
+#endif
}
typedef struct {
@@ -940,8 +954,12 @@ pre_exec_child_setup (gpointer data)
unset_cloexec (cdata->keepexec1);
if (cdata->keepexec2)
unset_cloexec (cdata->keepexec2);
+#ifdef WIN32
+ g_print ("implement priority handling\n");
+#else
/* drop scheduling priorities if we have any */
setpriority (PRIO_PROCESS, getpid(), 0);
+#endif
}
gchar*
@@ -955,6 +973,10 @@ sfi_com_spawn_async (const gchar *executable,
gint *command_output, /* readable */
SfiRing *args)
{
+#ifdef WIN32
+ g_print ("WIN32: implement sfi_com_spawn_async\n");
+ return NULL;
+#else
gint command_input_pipe[2] = { -1, -1 };
gint command_output_pipe[2] = { -1, -1 };
ChildSetupData setup_data = { -1, -1 };
@@ -971,7 +993,7 @@ sfi_com_spawn_async (const gchar *executable,
if (command_fd_option)
{
- if (pipe (command_output_pipe) < 0 || pipe (command_input_pipe) < 0)
+ if (pipe (command_output_pipe) < 0 || pipe (command_input_pipe) < 0)
{
gint e = errno;
@@ -1048,4 +1070,5 @@ sfi_com_spawn_async (const gchar *executable,
}
return reterr;
+#endif
}
diff --git a/sfi/sfifilecrawler.c b/sfi/sfifilecrawler.c
index 4d65e92..edfbfd3 100644
--- a/sfi/sfifilecrawler.c
+++ b/sfi/sfifilecrawler.c
@@ -509,7 +509,7 @@ sfi_make_dirpath (const gchar *dir)
struct stat st;
if (stat (str, &st) < 0) /* guard against existance */
{
- if (mkdir (str, 0755) < 0)
+ if (sfi_os_mkdir (str, 0755) < 0)
break;
}
}
@@ -601,7 +601,9 @@ g_file_test_all (const gchar *file,
return birnet_file_check (file, buffer);
}
+#ifndef WIN32
#include <pwd.h>
+#endif
static gchar*
get_user_home (const gchar *user,
diff --git a/sfi/sfistore.c b/sfi/sfistore.c
index c49af12..c2201c0 100644
--- a/sfi/sfistore.c
+++ b/sfi/sfistore.c
@@ -421,7 +421,7 @@ sfi_rstore_new_open (const gchar *fname)
}
if (fd >= 0 &&
(S_ISBLK (st.st_mode) ||
- S_ISLNK (st.st_mode)))
+ sfi_os_stat_is_link (st.st_mode)))
{
close (fd);
fd = -1;
diff --git a/sfi/sfitime.c b/sfi/sfitime.c
index 72be796..598be5e 100644
--- a/sfi/sfitime.c
+++ b/sfi/sfitime.c
@@ -60,7 +60,7 @@ _sfi_init_time (void)
t = tv.tv_sec + tv.tv_usec / 1000000;
/* we need to find out the timezone offset relative to GMT here */
-#if 0
+#ifdef WIN32
{ /* aparently FreeBSD/BSD4.3 doesn't have an extern long timezone; set by
* localtime(). if present, timezone contains # of seconds west of GMT.
*/
diff --git a/sfi/sfiwrapper.cc b/sfi/sfiwrapper.cc
index ec4907e..ad6c5bc 100644
--- a/sfi/sfiwrapper.cc
+++ b/sfi/sfiwrapper.cc
@@ -328,4 +328,23 @@ sfi_runtime_problem (char ewran_tag,
va_end (args);
}
+/* --- birnet OS --- */
+
+bool
+sfi_os_stat_is_socket (mode_t mode)
+{
+ return Birnet::OS::stat_is_socket (mode);
+}
+
+bool
+sfi_os_stat_is_link (mode_t mode)
+{
+ return Birnet::OS::stat_is_link (mode);
+}
+
+int
+sfi_os_mkdir (const char *path, mode_t mode)
+{
+ return Birnet::OS::mkdir (path, mode);
+}
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/sfi/sfiwrapper.h b/sfi/sfiwrapper.h
index 9aef8fd..6ee97de 100644
--- a/sfi/sfiwrapper.h
+++ b/sfi/sfiwrapper.h
@@ -284,6 +284,12 @@ void sfi_runtime_problem (char ewran_tag,
const char *msgformat,
...) BIRNET_PRINTF (6, 7);
+/* --- birnet OS layer --- */
+
+bool sfi_os_stat_is_socket (mode_t mode); /* S_ISSOCK */
+bool sfi_os_stat_is_link (mode_t mode); /* S_ISLNK */
+int sfi_os_mkdir (const char *path, mode_t mode);
+
BIRNET_EXTERN_C_END();
#endif /* __SFI_WRAPPER_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]