From 57eab4408bc999d23e870cf1566b9a47ba5d01e1 Mon Sep 17 00:00:00 2001 From: Waldemar Kornewald Date: Tue, 13 Dec 2005 16:30:16 +0000 Subject: [PATCH] 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 --- build/jam/BuildSetup | 2 +- src/bin/arp/Jamfile | 13 +- src/bin/ifconfig/Jamfile | 6 +- src/bin/ping/Jamfile | 6 +- src/bin/ppp_up/Jamfile | 2 +- src/bin/pppconfig/Jamfile | 2 +- src/bin/route/Jamfile | 6 +- src/bin/traceroute/Jamfile | 6 +- src/kits/network/compat/libbind/Jamfile | 3 +- src/kits/network/compat/libnet/Jamfile | 11 +- src/kits/network/compat/libnetapi/Jamfile | 9 +- src/kits/network/compat/libsocket/Jamfile | 28 +--- src/kits/network/compat/libsocket/select.c | 179 --------------------- 13 files changed, 25 insertions(+), 248 deletions(-) delete mode 100644 src/kits/network/compat/libsocket/select.c diff --git a/build/jam/BuildSetup b/build/jam/BuildSetup index 07bd5fc408..01a860f999 100644 --- a/build/jam/BuildSetup +++ b/build/jam/BuildSetup @@ -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 ; diff --git a/src/bin/arp/Jamfile b/src/bin/arp/Jamfile index 2c764ec96a..eb83c46107 100644 --- a/src/bin/arp/Jamfile +++ b/src/bin/arp/Jamfile @@ -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 ; -} diff --git a/src/bin/ifconfig/Jamfile b/src/bin/ifconfig/Jamfile index 685d528eda..70d44112f8 100644 --- a/src/bin/ifconfig/Jamfile +++ b/src/bin/ifconfig/Jamfile @@ -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) ; diff --git a/src/bin/ping/Jamfile b/src/bin/ping/Jamfile index b9d7468dba..272358ed05 100644 --- a/src/bin/ping/Jamfile +++ b/src/bin/ping/Jamfile @@ -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) ; diff --git a/src/bin/ppp_up/Jamfile b/src/bin/ppp_up/Jamfile index 558664020a..c9071b77ff 100644 --- a/src/bin/ppp_up/Jamfile +++ b/src/bin/ppp_up/Jamfile @@ -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 ; diff --git a/src/bin/pppconfig/Jamfile b/src/bin/pppconfig/Jamfile index 595c39f230..c43597a7ed 100644 --- a/src/bin/pppconfig/Jamfile +++ b/src/bin/pppconfig/Jamfile @@ -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 ; diff --git a/src/bin/route/Jamfile b/src/bin/route/Jamfile index 93c4014cd1..f3fb7680f4 100644 --- a/src/bin/route/Jamfile +++ b/src/bin/route/Jamfile @@ -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 route : keywords.c route.c diff --git a/src/bin/traceroute/Jamfile b/src/bin/traceroute/Jamfile index b9074c9054..1d3c081db3 100644 --- a/src/bin/traceroute/Jamfile +++ b/src/bin/traceroute/Jamfile @@ -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) ; diff --git a/src/kits/network/compat/libbind/Jamfile b/src/kits/network/compat/libbind/Jamfile index ac931768f3..bb3e7ed712 100644 --- a/src/kits/network/compat/libbind/Jamfile +++ b/src/kits/network/compat/libbind/Jamfile @@ -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 ) { diff --git a/src/kits/network/compat/libnet/Jamfile b/src/kits/network/compat/libnet/Jamfile index 2d41019eae..b1fd90dde2 100644 --- a/src/kits/network/compat/libnet/Jamfile +++ b/src/kits/network/compat/libnet/Jamfile @@ -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 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 diff --git a/src/kits/network/compat/libnetapi/Jamfile b/src/kits/network/compat/libnetapi/Jamfile index bcf782b775..77158a10df 100644 --- a/src/kits/network/compat/libnetapi/Jamfile +++ b/src/kits/network/compat/libnetapi/Jamfile @@ -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 and maybe other stuff. } -UsePrivateHeaders net ; - { - if ( $(TARGET_PLATFORM) = r5 ) { + if $(TARGET_PLATFORM) = r5 { defines = [ FDefines BUILDING_R5_LIBNET ] ; SubDirCcFlags $(defines) ; SubDirC++Flags $(defines) ; diff --git a/src/kits/network/compat/libsocket/Jamfile b/src/kits/network/compat/libsocket/Jamfile index 01b6dec9be..904e478eaa 100644 --- a/src/kits/network/compat/libsocket/Jamfile +++ b/src/kits/network/compat/libsocket/Jamfile @@ -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 ; diff --git a/src/kits/network/compat/libsocket/select.c b/src/kits/network/compat/libsocket/select.c deleted file mode 100644 index ebe601e519..0000000000 --- a/src/kits/network/compat/libsocket/select.c +++ /dev/null @@ -1,179 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -#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