This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
[patch] guile-core for BeOS
- To: guile at sourceware dot cygnus dot com
- Subject: [patch] guile-core for BeOS
- From: "Lars J. Aas" <larsa at sim dot no>
- Date: Tue, 21 Dec 1999 15:31:37 +0100
This patch makes guile-core compile/link/run under BeOS 4.5 (intel), and
the setup also worked on my x86 Linux server. I sent a small patch earlier
which only included arpa/inet.h wrappers, which also is included in this
patch...
configure setup changes:
header file tests:
arpa/inet.h HAVE_ARPA_INET_H
net/socket.h HAVE_NET_SOCKET_H
function tests:
fchmod() HAVE_FCHMOD
getsockopt() HAVE_GETSOCKOPT
definition tests:
S_ISSOCK in sys/stat.h HAVE_S_ISSOCK
structure field tests:
passwd.pw_gecos in pwd.h HAVE_PWD_GECOS
- BeOS' gcc doesn't like SCM_SYSCALL() macros dangling after if and else if
they aren't wrapped inside curly-braces, so the offending SCM_SYSCALLs
have been wrapped with curly braces
- the scm_getsockopt() function has been completely wrapped with the
HAVE_GETSOCKOPT define
- in scm_chmod() I wrapped the fchmod() part of the call with fallback on
returning SCM_SYSERR
- in scm_passwd() I used "" as a fallback for missing pw_gecos field
- in net_db.c, NETDB_INTERNAL is defined to -1 if it doesn't exist
- use of struct in_addr and select() -> added #include <net/socket.h>
Conclusion:
guile now compiles, builds and runs on BeOS
certain features have been disabled
use of select may not work at all, because of certain BeOS "features"[1]
Lars J
--
[1] sockets have their own "namespace" (hence there is no S_ISSOCK() in
stat.h), and select() has only been implemented for sockets. Be has
expressed that they will clean up the networking code for the next BeOS
release - which hopefully means that this problem will go away automagically.
Index: acconfig.h
===================================================================
RCS file: /cvs/guile/guile/guile-core/acconfig.h,v
retrieving revision 1.34
diff -u -r1.34 acconfig.h
--- acconfig.h 1999/11/19 18:16:18 1.34
+++ acconfig.h 1999/12/21 14:13:09
@@ -58,6 +58,9 @@
/* Define this if your system defines S_ISLNK in sys/stat.h */
#undef HAVE_S_ISLNK
+/* Define this if your system defines S_ISSOCK in sys/stat.h */
+#undef HAVE_S_ISSOCK
+
/* Define this if your system defines struct linger, for use with the
getsockopt and setsockopt system calls. */
#undef HAVE_STRUCT_LINGER
@@ -148,3 +151,6 @@
/* Define if the compiler supports long longs. */
#undef HAVE_LONG_LONGS
+
+/* Define if struct passwd in <pwd.h> includes a pw_gecos field. */
+#undef HAVE_PWD_GECOS
Index: configure.in
===================================================================
RCS file: /cvs/guile/guile/guile-core/configure.in,v
retrieving revision 1.104
diff -u -r1.104 configure.in
--- configure.in 1999/12/14 17:42:16 1.104
+++ configure.in 1999/12/21 14:13:09
@@ -123,7 +123,7 @@
AC_HEADER_DIRENT
AC_HEADER_TIME
AC_HEADER_SYS_WAIT
-AC_CHECK_HEADERS(io.h libc.h limits.h malloc.h memory.h string.h regex.h rxposix.h rx/rxposix.h sys/ioctl.h sys/select.h sys/time.h sys/timeb.h sys/times.h sys/types.h sys/utime.h time.h unistd.h utime.h)
+AC_CHECK_HEADERS(io.h libc.h limits.h malloc.h memory.h string.h regex.h rxposix.h rx/rxposix.h sys/ioctl.h sys/select.h sys/time.h sys/timeb.h sys/times.h sys/types.h sys/utime.h time.h unistd.h utime.h arpa/inet.h net/socket.h)
GUILE_HEADER_LIBC_WITH_UNISTD
AC_TYPE_GETGROUPS
@@ -169,7 +169,7 @@
GUILE_DLSYM_USCORE
-AC_CHECK_FUNCS(ctermid ftime getcwd geteuid gettimeofday lstat mkdir mknod nice readlink rename rmdir select setegid seteuid setlocale setpgid setsid sigaction siginterrupt strftime strptime symlink sync tcgetpgrp tcsetpgrp times uname waitpid bzero strdup system usleep atexit on_exit)
+AC_CHECK_FUNCS(ctermid ftime getcwd geteuid gettimeofday lstat mkdir mknod nice readlink rename rmdir select setegid seteuid setlocale setpgid setsid sigaction siginterrupt strftime strptime symlink sync tcgetpgrp tcsetpgrp times uname waitpid bzero strdup system usleep atexit on_exit fchmod getsockopt)
### Some systems don't declare some functions. On such systems, we
### need to at least provide our own K&R-style declarations.
@@ -307,6 +307,25 @@
ac_cv_macro_S_ISLNK=no)])
if test $ac_cv_macro_S_ISLNK = yes; then
AC_DEFINE(HAVE_S_ISLNK)
+fi
+
+AC_CACHE_CHECK([for S_ISSOCK in sys/stat.h], ac_cv_macro_S_ISSOCK,
+ [AC_TRY_CPP([#include <sys/stat.h>
+ #ifndef S_ISSOCK
+ #error no S_ISSOCK
+ #endif],
+ ac_cv_macro_S_ISSOCK=yes,
+ ac_cv_macro_S_ISSOCK=no)])
+if test $ac_cv_macro_S_ISSOCK = yes; then
+ AC_DEFINE(HAVE_S_ISSOCK)
+fi
+
+AC_CACHE_CHECK([for passwd.pw_gecos in pwd.h], ac_cv_macro_PWD_GECOS,
+ [AC_TRY_COMPILE([#include <pwd.h>], [struct passwd p; p.pw_gecos = (char *) 0L;],
+ ac_cv_macro_PWD_GECOS=yes,
+ ac_cv_macro_PWD_GECOS=no)])
+if test $ac_cv_macro_PWD_GECOS = yes; then
+ AC_DEFINE(HAVE_PWD_GECOS)
fi
AC_STRUCT_TIMEZONE
Index: libguile/filesys.c
===================================================================
RCS file: /cvs/guile/guile/guile-core/libguile/filesys.c,v
retrieving revision 1.57
diff -u -r1.57 filesys.c
--- filesys.c 1999/12/16 20:48:04 1.57
+++ filesys.c 1999/12/21 14:13:10
@@ -185,20 +185,25 @@
object = SCM_COERCE_OUTPORT (object);
SCM_VALIDATE_INT(2,mode);
- if (SCM_INUMP (object) || SCM_OPFPORTP (object))
+ if ( ! SCM_INUMP (object) && ! SCM_OPFPORTP (object))
{
+ SCM_VALIDATE_ROSTRING(1,object);
+ SCM_COERCE_SUBSTR (object);
+ SCM_SYSCALL (rv = chmod (SCM_ROCHARS (object), SCM_INUM (mode)));
+ }
+#ifdef HAVE_FCHMOD
+ else
+ {
if (SCM_INUMP (object))
fdes = SCM_INUM (object);
else
fdes = SCM_FPORT_FDES (object);
SCM_SYSCALL (rv = fchmod (fdes, SCM_INUM (mode)));
}
+#else
else
- {
- SCM_VALIDATE_ROSTRING(1,object);
- SCM_COERCE_SUBSTR (object);
- SCM_SYSCALL (rv = chmod (SCM_ROCHARS (object), SCM_INUM (mode)));
- }
+ rv = -1;
+#endif
if (rv == -1)
SCM_SYSERROR;
return SCM_UNSPECIFIED;
@@ -403,8 +408,10 @@
ve[13] = scm_sym_char_special;
else if (S_ISFIFO (mode))
ve[13] = scm_sym_fifo;
+#ifdef HAVE_S_ISSOCK
else if (S_ISSOCK (mode))
ve[13] = scm_sym_sock;
+#endif
else
ve[13] = scm_sym_unknown;
@@ -508,7 +515,9 @@
struct stat stat_temp;
if (SCM_INUMP (object))
- SCM_SYSCALL (rv = fstat (SCM_INUM (object), &stat_temp));
+ {
+ SCM_SYSCALL (rv = fstat (SCM_INUM (object), &stat_temp));
+ }
else
{
SCM_VALIDATE_NIM (1,object);
Index: libguile/fports.c
===================================================================
RCS file: /cvs/guile/guile/guile-core/libguile/fports.c,v
retrieving revision 1.56
diff -u -r1.56 fports.c
--- fports.c 1999/12/16 20:48:04 1.56
+++ fports.c 1999/12/21 14:13:10
@@ -62,6 +62,9 @@
#ifdef HAVE_ST_BLKSIZE
#include <sys/stat.h>
#endif
+#ifdef HAVE_NET_SOCKET_H
+#include <net/socket.h>
+#endif
#include <errno.h>
Index: libguile/inet_aton.c
===================================================================
RCS file: /cvs/guile/guile/guile-core/libguile/inet_aton.c,v
retrieving revision 1.4
diff -u -r1.4 inet_aton.c
--- inet_aton.c 1999/12/12 20:35:02 1.4
+++ inet_aton.c 1999/12/21 14:13:10
@@ -42,7 +42,12 @@
#include <sys/param.h>
#include <netinet/in.h>
+#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h>
+#endif
+#ifdef HAVE_NET_SOCKET_H
+#include <net/socket.h>
+#endif
#if 0
Index: libguile/net_db.c
===================================================================
RCS file: /cvs/guile/guile/guile-core/libguile/net_db.c,v
retrieving revision 1.26
diff -u -r1.26 net_db.c
--- net_db.c 1999/12/18 23:31:22 1.26
+++ net_db.c 1999/12/21 14:13:10
@@ -63,10 +63,15 @@
#endif
#include <sys/types.h>
+#ifdef HAVE_NET_SOCKET_H
+#include <net/socket.h>
+#endif
#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>
+#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h>
+#endif
/* Some systems do not declare this. Some systems do declare it, as a
macro. */
@@ -81,6 +86,10 @@
#endif /* STDC_HEADERS */
extern int inet_aton ();
+
+#ifndef NETDB_INTERNAL
+#define NETDB_INTERNAL -1
+#endif
GUILE_PROC (scm_inet_aton, "inet-aton", 1, 0, 0,
(SCM address),
Index: libguile/posix.c
===================================================================
RCS file: /cvs/guile/guile/guile-core/libguile/posix.c,v
retrieving revision 1.47
diff -u -r1.47 posix.c
--- posix.c 1999/12/16 20:48:04 1.47
+++ posix.c 1999/12/21 14:13:11
@@ -268,7 +268,11 @@
ve[1] = scm_makfrom0str (entry->pw_passwd);
ve[2] = scm_ulong2num ((unsigned long) entry->pw_uid);
ve[3] = scm_ulong2num ((unsigned long) entry->pw_gid);
+#if HAVE_PWD_GECOS
ve[4] = scm_makfrom0str (entry->pw_gecos);
+#else
+ ve[4] = scm_makfrom0str ("");
+#endif
if (!entry->pw_dir)
ve[5] = scm_makfrom0str ("");
else
@@ -323,7 +327,9 @@
}
}
else if (SCM_INUMP (name))
- SCM_SYSCALL (entry = getgrgid (SCM_INUM (name)));
+ {
+ SCM_SYSCALL (entry = getgrgid (SCM_INUM (name)));
+ }
else
{
SCM_VALIDATE_ROSTRING(1,name);
@@ -1104,12 +1110,16 @@
SCM_VALIDATE_ROSTRING(1,pathname);
SCM_COERCE_SUBSTR (pathname);
if (SCM_UNBNDP (actime))
- SCM_SYSCALL (time (&utm_tmp.actime));
+ {
+ SCM_SYSCALL (time (&utm_tmp.actime));
+ }
else
utm_tmp.actime = SCM_NUM2ULONG (2,actime);
if (SCM_UNBNDP (modtime))
- SCM_SYSCALL (time (&utm_tmp.modtime));
+ {
+ SCM_SYSCALL (time (&utm_tmp.modtime));
+ }
else
utm_tmp.modtime = SCM_NUM2ULONG (3,modtime);
@@ -1286,8 +1296,10 @@
ctype = S_IFCHR;
else if (strcmp (p, "fifo") == 0)
ctype = S_IFIFO;
+#ifdef HAVE_S_ISSOCK
else if (strcmp (p, "socket") == 0)
ctype = S_IFSOCK;
+#endif
else
SCM_OUT_OF_RANGE (2,type);
Index: libguile/socket.c
===================================================================
RCS file: /cvs/guile/guile/guile-core/libguile/socket.c,v
retrieving revision 1.40
diff -u -r1.40 socket.c
--- socket.c 1999/12/19 01:04:36 1.40
+++ socket.c 1999/12/21 14:13:11
@@ -61,13 +61,18 @@
#include <unistd.h>
#endif
#include <sys/types.h>
+#ifdef HAVE_NET_SOCKET_H
+#include <net/socket.h>
+#endif
#include <sys/socket.h>
#ifdef HAVE_UNIX_DOMAIN_SOCKETS
#include <sys/un.h>
#endif
#include <netinet/in.h>
#include <netdb.h>
+#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h>
+#endif
@@ -205,6 +210,7 @@
#undef FUNC_NAME
#endif
+#ifdef HAVE_GETSOCKOPT
GUILE_PROC (scm_getsockopt, "getsockopt", 3, 0, 0,
(SCM sock, SCM level, SCM optname),
"Returns the value of a particular socket option for the socket
@@ -274,6 +280,7 @@
return SCM_MAKINUM (*(int *) optval);
}
#undef FUNC_NAME
+#endif /* HAVE_GETSOCKOPT */
GUILE_PROC (scm_setsockopt, "setsockopt", 4, 0, 0,
(SCM sock, SCM level, SCM optname, SCM value),
Index: libguile/socket.h
===================================================================
RCS file: /cvs/guile/guile/guile-core/libguile/socket.h,v
retrieving revision 1.9
diff -u -r1.9 socket.h
--- socket.h 1999/11/18 22:36:28 1.9
+++ socket.h 1999/12/21 14:13:12
@@ -54,7 +54,9 @@
extern SCM scm_ntohl (SCM in);
extern SCM scm_socket (SCM family, SCM style, SCM proto);
extern SCM scm_socketpair (SCM family, SCM style, SCM proto);
+#ifdef HAVE_GETSOCKOPT
extern SCM scm_getsockopt (SCM sfd, SCM level, SCM optname);
+#endif /* HAVE_GETSOCKOPT */
extern SCM scm_setsockopt (SCM sfd, SCM level, SCM optname, SCM value);
extern SCM scm_shutdown (SCM sfd, SCM how);
extern SCM scm_connect (SCM sockfd, SCM fam, SCM address, SCM args);