Now we use the legacy headers when building our compatibility libraries. Fixed BuildSetup to use root instead of libroot.so because arp would not build otherwise. Command-line apps now don't build for R5, anymore. I hope nothing is broken.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15527 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Waldemar Kornewald
2005-12-13 16:30:16 +00:00
parent d49423aea3
commit 57eab4408b
13 changed files with 25 additions and 248 deletions
+1 -1
View File
@@ -457,7 +457,7 @@ if $(TARGET_PLATFORM) != haiku {
if $(TARGET_PLATFORM_BONE_COMPATIBLE) {
NETWORK_LIBS = libsocket.so libbind.so ;
NETAPI_LIB = libbnetapi.so ;
SELECT_UNAME_ETC_LIB = libroot.so ;
SELECT_UNAME_ETC_LIB = root ;
} else {
NETWORK_LIBS = libnet.so ;
NETAPI_LIB = libnetapi.so ;
+1 -12
View File
@@ -1,6 +1,6 @@
SubDir HAIKU_TOP src bin arp ;
SetSubDirSupportedPlatformsBeOSCompatible ;
SetSubDirSupportedPlatforms $(HAIKU_BONE_COMPATIBLE_PLATFORMS) ;
if $(TARGET_PLATFORM) != haiku {
UseHeaders [ FDirName $(HAIKU_TOP) headers posix ] : true ;
@@ -10,10 +10,6 @@ if $(TARGET_PLATFORM) != haiku {
UsePrivateHeaders net ;
if ! $(BONE_COMPATIBLE) {
SubDirCcFlags -DBUILDING_R5_LIBNET ;
}
BinCommand arp :
arp.c
: $(NETWORK_LIBS) $(SELECT_UNAME_ETC_LIB) ;
@@ -23,14 +19,7 @@ HaikuInstall install-networking
: [ FDirName $(HAIKU_TEST_DIR) kits net ]
: arp ;
# TODO: The build of arp is broken for target r5. The Haiku headers are used,
# but we link against libnet.so. Linking fails due to missing symbol __h_errno.
# However I doubt that this can work anyway, since the headers are simply
# not compatible with the R5 implementation, or is BUILDING_R5_LIBNET
# sufficient to make them so?
if $(TARGET_PLATFORM) != r5 {
Package haiku-networkingkit-cvs :
arp :
# boot home config bin ;
boot home Desktop haiku-networkingkit ;
}
+1 -5
View File
@@ -1,6 +1,6 @@
SubDir HAIKU_TOP src bin ifconfig ;
SetSubDirSupportedPlatformsBeOSCompatible ;
SetSubDirSupportedPlatforms $(HAIKU_BONE_COMPATIBLE_PLATFORMS) ;
if $(TARGET_PLATFORM) != haiku {
UseHeaders [ FDirName $(HAIKU_TOP) headers posix ] : true ;
@@ -10,10 +10,6 @@ if $(TARGET_PLATFORM) != haiku {
UsePrivateHeaders net ;
if ! $(BONE_COMPATIBLE) {
SubDirCcFlags -DBUILDING_R5_LIBNET -Dclose=closesocket ;
}
BinCommand ifconfig :
ifconfig.c
: $(NETWORK_LIBS) ;
+1 -5
View File
@@ -1,6 +1,6 @@
SubDir HAIKU_TOP src bin ping ;
SetSubDirSupportedPlatformsBeOSCompatible ;
SetSubDirSupportedPlatforms $(HAIKU_BONE_COMPATIBLE_PLATFORMS) ;
if $(TARGET_PLATFORM) != haiku {
UseHeaders [ FDirName $(HAIKU_TOP) headers posix ] : true ;
@@ -10,10 +10,6 @@ if $(TARGET_PLATFORM) != haiku {
UsePrivateHeaders net ;
if ! $(BONE_COMPATIBLE) {
SubDirCcFlags -DBUILDING_R5_LIBNET ;
}
BinCommand ping :
ping.c
: $(NETWORK_LIBS) $(SELECT_UNAME_ETC_LIB) ;
+1 -1
View File
@@ -1,6 +1,6 @@
SubDir HAIKU_TOP src bin ppp_up ;
SetSubDirSupportedPlatformsBeOSCompatible ;
SetSubDirSupportedPlatforms $(HAIKU_BONE_COMPATIBLE_PLATFORMS) ;
if $(TARGET_PLATFORM) != haiku {
UseHeaders [ FDirName $(HAIKU_TOP) headers posix ] : true ;
+1 -1
View File
@@ -1,6 +1,6 @@
SubDir HAIKU_TOP src bin pppconfig ;
SetSubDirSupportedPlatformsBeOSCompatible ;
SetSubDirSupportedPlatforms $(HAIKU_BONE_COMPATIBLE_PLATFORMS) ;
if $(TARGET_PLATFORM) != haiku {
UseHeaders [ FDirName $(HAIKU_TOP) headers posix ] : true ;
+1 -5
View File
@@ -1,6 +1,6 @@
SubDir HAIKU_TOP src bin route ;
SetSubDirSupportedPlatformsBeOSCompatible ;
SetSubDirSupportedPlatforms $(HAIKU_BONE_COMPATIBLE_PLATFORMS) ;
if $(TARGET_PLATFORM) != haiku {
UseHeaders [ FDirName $(HAIKU_TOP) headers posix ] : true ;
@@ -10,10 +10,6 @@ if $(TARGET_PLATFORM) != haiku {
UsePrivateHeaders net ;
if ! $(BONE_COMPATIBLE) {
SubDirCcFlags -DBUILDING_R5_LIBNET ;
}
BinCommand <bin>route :
keywords.c
route.c
+1 -5
View File
@@ -1,6 +1,6 @@
SubDir HAIKU_TOP src bin traceroute ;
SetSubDirSupportedPlatformsBeOSCompatible ;
SetSubDirSupportedPlatforms $(HAIKU_BONE_COMPATIBLE_PLATFORMS) ;
if $(TARGET_PLATFORM) != haiku {
UseHeaders [ FDirName $(HAIKU_TOP) headers posix ] : true ;
@@ -10,10 +10,6 @@ if $(TARGET_PLATFORM) != haiku {
UsePrivateHeaders net ;
if ! $(BONE_COMPATIBLE) {
SubDirCcFlags -DBUILDING_R5_LIBNET ;
}
BinCommand traceroute :
traceroute.c
: $(NETWORK_LIBS) $(SELECT_UNAME_ETC_LIB) ;
+2 -1
View File
@@ -2,8 +2,9 @@ SubDir HAIKU_TOP src kits network compat libbind ;
SetSubDirSupportedPlatformsBeOSCompatible ;
UsePrivateHeaders net ;
UseHeaders [ FDirName $(SUBDIR) headers ] : true ;
UsePrivateHeaders net ;
UseHeaders [ FDirName $(HAIKU_TOP) headers legacy network ] : true ;
SubDirSysHdrs $(SUBDIR) ;
if ( $(TARGET_PLATFORM) != haiku ) {
+6 -5
View File
@@ -4,8 +4,9 @@ SetSubDirSupportedPlatformsBeOSCompatible ;
UseHeaders [ FDirName $(SUBDIR) headers ] : true ;
UsePrivateHeaders net ;
UseHeaders [ FDirName $(HAIKU_TOP) headers legacy network ] : true ;
if ( $(TARGET_PLATFORM) != haiku ) {
if $(TARGET_PLATFORM) != haiku {
UseHeaders [ FDirName $(HAIKU_TOP) headers posix ] : true ;
# We need the public network headers also when not compiling for Haiku.
# Unfortunately we get more than we want, namely all POSIX headers.
@@ -21,12 +22,12 @@ if ( $(TARGET_PLATFORM) != haiku ) {
# BONE versions of the inet_* functions are prefixed with __ in <arpa/inet.h> and
# implemented in libbind.so as are ours.
local defines ;
if ( $(TARGET_PLATFORM) = r5 ) {
if $(TARGET_PLATFORM) = r5 {
defines += BUILDING_R5_LIBNET ;
} else if ( $(TARGET_PLATFORM) = bone ) {
} else if $(TARGET_PLATFORM) = bone {
defines += BONE_VERSION ;
defines += BUILDING_R5_LIBNET ;
} else if ( $(TARGET_PLATFORM) = haiku ) {
} else if $(TARGET_PLATFORM) = haiku {
defines += BUILDING_R5_LIBNET ;
}
defines = [ FDefines $(defines) ] ;
@@ -36,7 +37,7 @@ if ( $(TARGET_PLATFORM) != haiku ) {
#Depends libnet.so : install_network_etc_files ;
if ( $(TARGET_PLATFORM) = r5 ) {
if $(TARGET_PLATFORM) = r5 {
PLATFORM_SOURCES =
select.c
poll.c
+5 -4
View File
@@ -2,7 +2,10 @@ SubDir HAIKU_TOP src kits network compat libnetapi ;
SetSubDirSupportedPlatformsBeOSCompatible ;
if ( $(TARGET_PLATFORM) != haiku ) {
UsePrivateHeaders net ;
UseHeaders [ FDirName $(HAIKU_TOP) headers legacy network ] : true ;
if $(TARGET_PLATFORM) != haiku {
UseHeaders [ FDirName $(HAIKU_TOP) headers posix ] : true ;
# We need the public network headers also when not compiling for Haiku.
# Unfortunately we get more than we want, namely all POSIX headers.
@@ -10,10 +13,8 @@ if ( $(TARGET_PLATFORM) != haiku ) {
# Needed for <net/*.h> and maybe other stuff.
}
UsePrivateHeaders net ;
{
if ( $(TARGET_PLATFORM) = r5 ) {
if $(TARGET_PLATFORM) = r5 {
defines = [ FDefines BUILDING_R5_LIBNET ] ;
SubDirCcFlags $(defines) ;
SubDirC++Flags $(defines) ;
+4 -24
View File
@@ -2,42 +2,22 @@ SubDir HAIKU_TOP src kits network compat libsocket ;
SetSubDirSupportedPlatformsBeOSCompatible ;
if ( $(TARGET_PLATFORM) != haiku ) {
UsePrivateHeaders net ;
UseHeaders [ FDirName $(HAIKU_TOP) headers legacy network ] : true ;
if $(TARGET_PLATFORM) != haiku {
UseHeaders [ FDirName $(HAIKU_TOP) headers posix ] : true ;
# We need the public network headers also when not compiling for Haiku.
# Unfortunately we get more than we want, namely all POSIX headers.
}
UsePrivateHeaders net ;
{
# Default libs include BeOS R5 libnet.so, something we don't want here!
LINKFLAGS on libsocket.so = [ on libsocket.so return $(LINKFLAGS) ] -nodefaultlibs ;
local defines ;
if ( $(TARGET_PLATFORM) = r5 ) {
defines += BUILDING_R5_LIBNET ;
} else if ( $(TARGET_PLATFORM) = bone ) {
defines += BONE_VERSION ;
}
defines = [ FDefines $(defines) ] ;
SubDirCcFlags $(defines) ;
SubDirC++Flags $(defines) ;
}
if ( $(TARGET_PLATFORM) = bone ) {
PLATFORM_SOURCES =
select.c
;
} else {
# under Haiku we don't need the above
# because it's in libroot.so
PLATFORM_SOURCES = ;
}
SharedLibrary libsocket.so :
socket.c
$(PLATFORM_SOURCES)
: root
;
-179
View File
@@ -1,179 +0,0 @@
#include <unistd.h>
#include <image.h>
#include <OS.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/select.h>
#include <errno.h>
#include "net_stack_driver.h"
#ifndef BONE_VERSION
static int fd_set_count(fd_set * bits, int nbits)
{
int count;
int fd;
count = 0;
for (fd = 0; fd < nbits; fd++)
if (FD_ISSET(fd, bits))
count++;
return count;
}
_EXPORT int select(int nbits, struct fd_set * rbits,
struct fd_set * wbits,
struct fd_set * ebits,
struct timeval * tv)
{
int fd;
int n;
struct stack_driver_args args;
status_t status;
area_id area;
struct r5_selectsync * rss;
#define ROUND_TO_PAGE_SIZE(x) (((x) + (B_PAGE_SIZE) - 1) & ~((B_PAGE_SIZE) - 1))
// We share a area with the fd_set on it with the network stack code.
// The r5_notify_select_event in the net_stack_driver code will fill it and wakeup us
// when a event raise.
area = create_area("r5_selectsync", (void **) &rss,
B_ANY_ADDRESS, ROUND_TO_PAGE_SIZE(sizeof(*rss)), B_NO_LOCK,
B_READ_AREA | B_WRITE_AREA);
if (area < B_OK) {
errno = area;
return -1;
};
// The area is multi-thread protected by a semaphore locker
rss->lock = create_sem(1, "r5_selectsync_lock");
if (rss->lock < B_OK) {
errno = rss->lock;
rss->wakeup = 0;
n = -1;
goto error;
};
// Create the wakeup call semaphore
rss->wakeup = create_sem(0, "r5_selectsync_wakeup");
if (rss->wakeup < B_OK) {
errno = rss->wakeup;
n = -1;
goto error;
};
FD_ZERO(&rss->rbits);
FD_ZERO(&rss->wbits);
FD_ZERO(&rss->ebits);
/* Beware, ugly hacky hack: we pass the area_id of our shared r5_selectsync,
that net_stack_driver should udate directly
*/
args.u.select.sync = (struct selectsync *) area;
/* call, indirectly, net_stack_select() for each event to monitor
* as we are not the vfs, we can't call this device hook ourself, but
* our NET_STACK_SELECT opcode would do it for us...
*/
n = 0;
for (fd = 0; fd < nbits; fd++) {
if (rbits && FD_ISSET(fd, rbits)) {
args.u.select.ref = (fd << 8) | 1;
if (ioctl(fd, NET_STACK_SELECT, &args, sizeof(args)) >= 0)
n++;
};
if (wbits && FD_ISSET(fd, wbits)) {
args.u.select.ref = (fd << 8) | 2;
if (ioctl(fd, NET_STACK_SELECT, &args, sizeof(args)) >= 0)
n++;
};
if (ebits && FD_ISSET(fd, ebits)) {
args.u.select.ref = (fd << 8) | 3;
if (ioctl(fd, NET_STACK_SELECT, &args, sizeof(args)) >= 0)
n++;
};
}
if (n < 1) {
// TODO: maybe we could hack a workaround for select() on file/dev here:
// If no fd handle the NET_STACK_SELECT, assume they're files, so always
// readable and writable?
errno = B_BAD_VALUE;
n = -1;
goto error;
};
// Okay, now wait for our wakeup call.
// Maybe his's already there, even... (when the select event is already raised)
if (tv) {
bigtime_t timeout;
timeout = tv->tv_sec * 1000000LL + tv->tv_usec;
status = acquire_sem_etc(rss->wakeup, 1, B_RELATIVE_TIMEOUT | B_CAN_INTERRUPT, timeout);
} else
status = acquire_sem(rss->wakeup);
// we don't need it anymore, and we say "select() party is over" that way, too :-)
delete_sem(rss->lock);
delete_sem(rss->wakeup);
rss->lock = rss->wakeup = -1;
// unregister socket event notification
for(fd = 0; fd < nbits; fd++) {
if (rbits && FD_ISSET(fd, rbits)) {
args.u.select.ref = (fd << 8) | 1;
ioctl(fd, NET_STACK_DESELECT, &args, sizeof(args));
};
if (wbits && FD_ISSET(fd, wbits)) {
args.u.select.ref = (fd << 8) | 2;
ioctl(fd, NET_STACK_DESELECT, &args, sizeof(args));
};
if (ebits && FD_ISSET(fd, ebits)) {
args.u.select.ref = (fd << 8) | 3;
ioctl(fd, NET_STACK_DESELECT, &args, sizeof(args));
};
};
// Okay, what the final result?
switch (status) {
case B_OK:
case B_WOULD_BLOCK:
case B_TIMED_OUT: // logicly, 'n' should stay to 0 in this case...
n = 0;
if (rbits) {
memcpy(rbits, &rss->rbits, sizeof(*rbits));
n += fd_set_count(rbits, nbits);
};
if (wbits) {
memcpy(wbits, &rss->wbits, sizeof(*wbits));
n += fd_set_count(wbits, nbits);
};
if (ebits) {
memcpy(ebits, &rss->ebits, sizeof(*ebits));
n += fd_set_count(ebits, nbits);
};
break;
default:
errno = status;
n = -1;
break;
};
error:
if (rss->lock >= 0)
delete_sem(rss->lock);
if (rss->wakeup >= 0)
delete_sem(rss->wakeup);
delete_area(area);
return n;
}
#endif // !BONE_VERSION