Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
emulab
emulab-devel
Commits
42af20cb
Commit
42af20cb
authored
Oct 05, 2004
by
Russ Fish
Browse files
Miscellaneous fixes to support compilation on CygWin.
parent
40c6de55
Changes
7
Hide whitespace changes
Inline
Side-by-side
event/lib/GNUmakefile.in
View file @
42af20cb
...
...
@@ -14,7 +14,8 @@ include $(OBJDIR)/Makeconf
SYSTEM := $(shell uname -s)
LIBS = libevent.a
SWIGLIBS =
ifneq ($(SYSTEM),Linux)
# Re-entrant, multi-threaded version on FreeBSD, not on Linux or Windows clients.
ifeq ($(SYSTEM),FreeBSD)
LIBS += libevent_r.a
SWIGLIBS += event.so _tbevent.so
endif
...
...
event/program-agent/program-agent.c
View file @
42af20cb
...
...
@@ -455,6 +455,44 @@ const char *const sys_signame[NSIG] = {
"sys"
,
/* SIGSYS */
};
#endif
#ifdef __CYGWIN__
#undef NSIG
#define NSIG 32
const
char
*
const
sys_signame
[
NSIG
]
=
{
"Signal 0"
,
"hup"
,
/* SIGHUP */
"int"
,
/* SIGINT */
"quit"
,
/* SIGQUIT */
"ill"
,
/* SIGILL */
"trap"
,
/* SIGTRAP */
"abrt"
,
/* SIGABRT */
"emt"
,
/* SIGEMT */
"fpe"
,
/* SIGFPE */
"kill"
,
/* SIGKILL */
"bus"
,
/* SIGBUS */
"segv"
,
/* SIGSEGV */
"sys"
,
/* SIGSYS */
"pipe"
,
/* SIGPIPE */
"alrm"
,
/* SIGALRM */
"term"
,
/* SIGTERM */
"urg"
,
/* SIGURG */
"stop"
,
/* SIGSTOP */
"tstp"
,
/* SIGTSTP */
"cont"
,
/* SIGCONT */
"chld"
,
/* SIGCHLD */
"ttin"
,
/* SIGTTIN */
"ttou"
,
/* SIGTTOU */
"io"
,
/* SIGIO */
"xcpu"
,
/* SIGXCPU */
"xfsz"
,
/* SIGXFSZ */
"vtalrm"
,
/* SIGVTALRM */
"prof"
,
/* SIGPROF */
"winch"
,
/* SIGWINCH */
"lost"
,
/* SIGLOST */
"usr1"
,
/* SIGUSR1 */
"usr2"
,
/* SIGUSR2 */
};
#endif
static
void
signal_program
(
struct
proginfo
*
pinfo
,
char
*
args
)
...
...
event/trafgen/GNUmakefile.in
View file @
42af20cb
...
...
@@ -47,7 +47,7 @@ LDFLAGS += -L../lib -L${OBJDIR}/lib/libtb
LIBS += -levent -ltb -lcrypto
LIBS += `elvin-config --libs vin4c`
SYSTEM
:= $(shell uname -s)
SYSTEM := $(shell uname -s)
ifeq ($(SYSTEM),FreeBSD)
# FreeBSD
...
...
@@ -56,6 +56,13 @@ YCFLAGS += -I. -I$(TGSRCDIR) -DUSEEVENTS -DFREEBSD
LIBS += -ll -lcompat
endif
ifeq ($(SYSTEM),CYGWIN_NT-5.1)
# Cygwin on Windows XP - resembles the Linux case.
CFLAGS += -DCYGWIN -DLINUX
YCFLAGS += -I. -I$(TGSRCDIR) -DUSEEVENTS -DCYGWIN -DLINUX
LIBS += -lfl
endif
ifeq ($(SYSTEM),Linux)
# Linux
NEEDKERB := $(shell nm /usr/lib/libssl.a | grep -q krb; echo $$?)
...
...
os/GNUmakefile.in
View file @
42af20cb
...
...
@@ -28,7 +28,7 @@ control-install:
@$(MAKE) -C imagezip install
client:
if
n
eq ($(SYSTEM),
Linux
)
ifeq ($(SYSTEM),
FreeBSD
)
$(MAKE) -C growdisk client
endif
$(MAKE) -C syncd client
...
...
@@ -39,7 +39,7 @@ client-install: client
$(INSTALL) -m 755 -o root -g wheel -d $(LBINDIR)
$(INSTALL_PROGRAM) $(SRCDIR)/install-tarfile $(LBINDIR)/install-tarfile
$(INSTALL_PROGRAM) $(SRCDIR)/install-rpm $(LBINDIR)/install-rpm
if
n
eq ($(SYSTEM),
Linux
)
ifeq ($(SYSTEM),
FreeBSD
)
$(INSTALL_PROGRAM) $(SRCDIR)/create-image $(LBINDIR)/create-image
$(MAKE) -C growdisk client-install
endif
...
...
@@ -48,12 +48,12 @@ endif
$(MAKE) -C genhostsfile client-install
mfs:
if
n
eq ($(SYSTEM),
Linux
)
ifeq ($(SYSTEM),
FreeBSD
)
$(MAKE) -C imagezip client
endif
mfs-install: mfs
if
n
eq ($(SYSTEM),
Linux
)
ifeq ($(SYSTEM),
FreeBSD
)
$(INSTALL_PROGRAM) $(SRCDIR)/create-image $(LBINDIR)/create-image
$(MAKE) -C imagezip client-install
endif
...
...
sensors/slothd/slothd.c
View file @
42af20cb
...
...
@@ -466,6 +466,16 @@ void get_min_tty_idle(SLOTHD_PACKET *pkt) {
return
;
}
#ifdef __CYGWIN__
int
getloadavg
(
double
loadavg
[],
int
nelem
)
{
FILE
*
f
=
fopen
(
"/proc/loadavg"
,
"r"
);
fscanf
(
f
,
"%lf %lf %lf"
,
&
loadavg
[
0
],
&
loadavg
[
1
],
&
loadavg
[
2
]);
fclose
(
f
);
return
3
;
}
#endif
/* __CYGWIN__ */
void
get_load
(
SLOTHD_PACKET
*
pkt
)
{
...
...
@@ -542,10 +552,14 @@ int get_active_bits(SLOTHD_PACKET *pkt, SLOTHD_PACKET *opkt) {
void
get_packet_counts
(
SLOTHD_PACKET
*
pkt
)
{
#ifndef __CYGWIN__
int
i
;
char
*
niprog
[]
=
{
"netstat"
,
"-ni"
,
NULL
};
#endif
/* __CYGWIN__ */
pkt
->
ifcnt
=
0
;
#ifndef __CYGWIN__
if
(
procpipe
(
niprog
,
&
get_counters
,
(
void
*
)
pkt
))
{
lwarn
(
"Netinfo exec failed."
);
pkt
->
ifcnt
=
0
;
...
...
@@ -558,9 +572,11 @@ void get_packet_counts(SLOTHD_PACKET *pkt) {
pkt
->
ifaces
[
i
].
opkts
);
}
}
#endif
/* __CYGWIN__ */
return
;
}
#ifndef __CYGWIN__
int
get_counters
(
char
*
buf
,
void
*
data
)
{
SLOTHD_PACKET
*
pkt
=
(
SLOTHD_PACKET
*
)
data
;
...
...
@@ -607,7 +623,7 @@ int get_counters(char *buf, void *data) {
}
return
0
;
}
#endif
/* __CYGWIN__ */
/* XXX change to combine last return value of procfunc with exec'ed process'
exit status & write macros for access.
...
...
tmcd/findif.c
View file @
42af20cb
...
...
@@ -40,30 +40,28 @@
#include
<stdio.h>
#include
<string.h>
#include
<stdlib.h>
#ifndef __CYGWIN__
#include
<sys/param.h>
#include
<sys/ioctl.h>
#include
<sys/socket.h>
#include
<sys/sysctl.h>
#include
<netinet/in.h>
#include
<net/ethernet.h>
#include
<net/if.h>
#endif
/* __CYGWIN__ */
#ifdef __FreeBSD__
#include
<err.h>
#include
<net/if.h>
#include
<net/if_dl.h>
#include
<net/if_types.h>
#include
<net/route.h>
#endif
#ifdef linux
#include
<net/if.h>
#include
<string.h>
#endif
static
int
find_iface
(
char
*
mac
);
void
usage
()
{
fprintf
(
stderr
,
"usage: f
oo
<macaddr>
\n
"
);
fprintf
(
stderr
,
"usage: f
indif
<macaddr>
\n
"
);
exit
(
1
);
}
...
...
@@ -220,3 +218,46 @@ find_iface(char *macaddr)
return
1
;
}
#endif
#ifdef __CYGWIN__
static
int
find_iface
(
char
*
macaddr
)
{
FILE
*
fp
=
popen
(
"getmac /nh /v /fo csv"
,
"r"
);
char
buf
[
BUFSIZ
];
while
(
fgets
(
buf
,
BUFSIZ
,
fp
)
!=
NULL
)
{
char
*
comma1
,
*
comma2
,
mac
[
13
],
*
mc
;
int
i
;
/* The first comma-separated field is the name with quotes, and the
* third is the MAC addr, with quotes and dash separators.
*/
comma1
=
index
(
buf
,
','
);
if
(
comma1
==
NULL
)
continue
;
/* Skip blank line. */
comma2
=
index
(
comma1
+
1
,
','
);
if
(
comma2
==
NULL
)
continue
;
/* Shouldn't happen. */
/* The MAC argument we're comparing against has no separators.
* Dump the dashes.
*/
mc
=
comma2
+
2
;
for
(
i
=
0
;
i
<
6
;
i
++
)
{
mac
[
i
*
2
]
=
*
mc
++
;
mac
[
i
*
2
+
1
]
=
*
mc
++
;
mc
++
;
}
mac
[
12
]
=
'\0'
;
/* printf("%s %s\n", buf, mac); */
if
(
strcasecmp
(
mac
,
macaddr
)
==
0
)
{
*
(
comma1
-
1
)
=
'\0'
;
/* Prune the quotes. */
printf
(
"%s
\n
"
,
buf
+
1
);
pclose
(
fp
);
return
0
;
}
}
pclose
(
fp
);
return
1
;
}
#endif
/* __CYGWIN__ */
tmcd/tmcc.c
View file @
42af20cb
...
...
@@ -16,8 +16,8 @@ typedef int socklen_t;
#include
<sys/types.h>
#ifndef _WIN32
#include
<sys/socket.h>
#include
<netinet/in.h>
#
include <sys/socket.h>
#
include <netinet/in.h>
#endif
#include
<sys/un.h>
#include
<sys/fcntl.h>
...
...
@@ -26,6 +26,9 @@ typedef int socklen_t;
#include
<syslog.h>
#include
<unistd.h>
#include
<signal.h>
#ifdef __CYGWIN__
typedef
_sig_func_ptr
sig_t
;
#endif
/* __CYGWIN__ */
#include
<stdarg.h>
#include
<stdlib.h>
#include
<string.h>
...
...
@@ -35,25 +38,25 @@ typedef int socklen_t;
#include
<assert.h>
#include
<sys/types.h>
#ifndef _WIN32
#include
<netinet/in.h>
#include
<arpa/inet.h>
#include
<netdb.h>
#
include <netinet/in.h>
#
include <arpa/inet.h>
#
include <netdb.h>
#endif
#include
"decls.h"
#include
"ssl.h"
#ifndef STANDALONE
#include
"config.h"
#
include "config.h"
#endif
#ifndef _WIN32
#undef BOSSNODE
#
ifndef BOSSNODE
#include
<resolv.h>
#endif
#
undef BOSSNODE
#
if !defined(BOSSNODE) && !defined(__CYGWIN__)
#
include <resolv.h>
#
endif
#endif
#include
<setjmp.h>
#ifndef KEYFILE
#define KEYFILE "/etc/emulab.pkey"
#
define KEYFILE "/etc/emulab.pkey"
#endif
/*
...
...
@@ -364,7 +367,6 @@ getbossnode(char **bossnode, int *portp)
*
bossnode
=
strdup
(
BOSSNODE
);
return
0
;
#else
struct
hostent
*
he
;
FILE
*
fp
;
char
buf
[
BUFSIZ
],
**
cp
=
bossnodedirs
,
*
bp
;
...
...
@@ -415,18 +417,23 @@ getbossnode(char **bossnode, int *portp)
}
}
#ifndef _WIN32
/*
* Nameserver goo
*/
res_init
();
he
=
gethostbyaddr
((
char
*
)
&
_res
.
nsaddr
.
sin_addr
,
sizeof
(
struct
in_addr
),
AF_INET
);
if
(
he
&&
he
->
h_name
)
*
bossnode
=
strdup
(
he
->
h_name
);
else
#endif
*
bossnode
=
strdup
(
"UNKNOWN"
);
# if ! defined(_WIN32) && ! defined(__CYGWIN__)
{
/*
* Nameserver goo
*/
struct
hostent
*
he
;
res_init
();
he
=
gethostbyaddr
((
char
*
)
&
_res
.
nsaddr
.
sin_addr
,
sizeof
(
struct
in_addr
),
AF_INET
);
if
(
he
&&
he
->
h_name
)
*
bossnode
=
strdup
(
he
->
h_name
);
else
*
bossnode
=
strdup
(
"UNKNOWN"
);
return
0
;
}
# endif
*
bossnode
=
strdup
(
"UNKNOWN"
);
return
0
;
#endif
}
...
...
@@ -481,7 +488,7 @@ dotcp(char *data, int outfd, struct in_addr serverip)
connected
=
1
;
n
=
1
;
if
(
setsockopt
(
sock
,
SOL_SOCKET
,
SO_KEEPALIVE
,
&
n
,
sizeof
(
n
))
<
0
)
{
if
(
setsockopt
(
sock
,
SOL_SOCKET
,
SO_KEEPALIVE
,
(
void
*
)
&
n
,
sizeof
(
n
))
<
0
)
{
perror
(
"setsockopt SO_KEEPALIVE"
);
goto
bad
;
}
...
...
@@ -591,7 +598,10 @@ dounix(char *data, int outfd, char *unixpath)
sunaddr
.
sun_family
=
AF_UNIX
;
strlcpy
(
sunaddr
.
sun_path
,
unixpath
,
sizeof
(
sunaddr
.
sun_path
));
sunaddr
.
sun_len
=
length
=
SUN_LEN
(
&
sunaddr
)
+
1
;
length
=
SUN_LEN
(
&
sunaddr
)
+
1
;
# ifndef __CYGWIN__
sunaddr
.
sun_len
=
length
;
# endif
/* __CYGWIN__ */
/* Create socket from which to read. */
sock
=
socket
(
AF_UNIX
,
SOCK_STREAM
,
0
);
...
...
@@ -693,8 +703,11 @@ beproxy(char *localpath, struct in_addr serverip, char *partial)
memset
(
&
sunaddr
,
0
,
sizeof
(
sunaddr
));
sunaddr
.
sun_family
=
AF_UNIX
;
strlcpy
(
sunaddr
.
sun_path
,
localpath
,
sizeof
(
sunaddr
.
sun_path
));
sunaddr
.
sun_len
=
SUN_LEN
(
&
sunaddr
)
+
1
;
if
(
bind
(
sock
,
(
struct
sockaddr
*
)
&
sunaddr
,
sunaddr
.
sun_len
)
<
0
)
{
length
=
SUN_LEN
(
&
sunaddr
)
+
1
;
# ifndef __CYGWIN__
sunaddr
.
sun_len
=
length
;
# endif
/* __CYGWIN__ */
if
(
bind
(
sock
,
(
struct
sockaddr
*
)
&
sunaddr
,
length
)
<
0
)
{
perror
(
"binding unix domain socket"
);
exit
(
-
1
);
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment