From 8a3c51251639ef9d6bccef5a4fb537f288719c0c Mon Sep 17 00:00:00 2001 From: Philippe Houdoin Date: Sun, 3 Oct 2004 15:10:25 +0000 Subject: [PATCH] Fix build issues after select() kernel support API was added to public definition in headers/os/kernel/. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9166 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../drivers/network/stack/net_server_driver.c | 35 ++++++------ .../drivers/network/stack/net_stack_driver.c | 53 ++++++++++--------- 2 files changed, 47 insertions(+), 41 deletions(-) diff --git a/src/add-ons/kernel/drivers/network/stack/net_server_driver.c b/src/add-ons/kernel/drivers/network/stack/net_server_driver.c index f907f25640..94882ffbef 100644 --- a/src/add-ons/kernel/drivers/network/stack/net_server_driver.c +++ b/src/add-ons/kernel/drivers/network/stack/net_server_driver.c @@ -15,13 +15,13 @@ #else // Public includes +#include +#include + #include #include #include -// Posix includes -#include -#include #include // Private includes @@ -30,13 +30,6 @@ #include #include -/* these are missing from KernelExport.h ... */ -#define B_SELECT_READ 1 -#define B_SELECT_WRITE 2 -#define B_SELECT_EXCEPTION 3 - -extern void notify_select_event(selectsync * sync, uint32 ref); - //*****************************************************/ // Debug output //*****************************************************/ @@ -79,7 +72,12 @@ extern void notify_select_event(selectsync * sync, uint32 ref); /* wait one second when waiting on the stack */ #define STACK_TIMEOUT 1000000LL -typedef void (*notify_select_event_function)(selectsync * sync, uint32 ref); +#ifdef COMPILE_FOR_R5 + typedef status_t (*notify_select_event_function)(selectsync * sync, uint32 ref); +#else + typedef status_t (*notify_select_event_function)(selectsync * sync, uint32 ref, uint8 event); +#endif + // this struct will store one select() event to monitor per thread typedef struct selecter { @@ -127,7 +125,7 @@ static status_t net_server_deselect(void *cookie, uint8 event, selectsync *sync) /* select() support */ static int32 socket_event_listener(void *data); static void on_socket_event(void *socket, uint32 event, void *cookie); -static void r5_notify_select_event(selectsync *sync, uint32 ref); +static status_t r5_notify_select_event(selectsync *sync, uint32 ref, uint8 event); /* command queue */ static status_t init_connection(void **cookie); @@ -517,7 +515,11 @@ static void on_socket_event(void *socket, uint32 event, void *cookie) while (s) { if (s->event == event) // notify this selecter (thread/event pair) +#ifdef COMPILE_FOR_R5 g_nse(s->sync, s->ref); +#else + g_nse(s->sync, s->ref, (uint8) event); +#endif s = s->next; }; @@ -533,7 +535,7 @@ static void on_socket_event(void *socket, uint32 event, void *cookie) So, here is our own notify_select_event() implementation, the driver-side pair of the our libnet.so select() implementation... */ -static void r5_notify_select_event(selectsync *sync, uint32 ref) +static status_t r5_notify_select_event(selectsync *sync, uint32 ref, uint8 event) { area_id area; struct r5_selectsync *rss; @@ -548,7 +550,7 @@ static void r5_notify_select_event(selectsync *sync, uint32 ref) #if SHOW_INSANE_DEBUGGING dprintf(LOGID "r5_notify_select_event: clone_area(%d) failed -> %d!\n", (area_id) sync, area); #endif - return; + return area; }; #if SHOW_INSANE_DEBUGGING @@ -562,14 +564,14 @@ static void r5_notify_select_event(selectsync *sync, uint32 ref) goto error; fd = ref >> 8; - switch (ref & 0xFF) { + switch (ref & 0xFF) { // event == ref & 0xFF ! case B_SELECT_READ: FD_SET(fd, &rss->rbits); break; case B_SELECT_WRITE: FD_SET(fd, &rss->wbits); break; - case B_SELECT_EXCEPTION: + case B_SELECT_ERROR: FD_SET(fd, &rss->ebits); break; }; @@ -581,6 +583,7 @@ static void r5_notify_select_event(selectsync *sync, uint32 ref) error: delete_area(area); + return B_ERROR; } diff --git a/src/add-ons/kernel/drivers/network/stack/net_stack_driver.c b/src/add-ons/kernel/drivers/network/stack/net_stack_driver.c index c7218cb1a8..1a86a8d2ee 100644 --- a/src/add-ons/kernel/drivers/network/stack/net_stack_driver.c +++ b/src/add-ons/kernel/drivers/network/stack/net_stack_driver.c @@ -1,7 +1,7 @@ /* net_stack_driver.c * * This file implements a very simple socket driver that is intended to - * act as an interface to the new networking stack. + * act as an interface to the networking stack. */ #ifndef _KERNEL_MODE @@ -11,28 +11,21 @@ #else // Public/system includes +#include +#include + #include #include #include #include // For get_module()/put_module() -#include #include -#include -#include - // Private includes +#include #include #include -/* these are missing from KernelExport.h ... */ -#define B_SELECT_READ 1 -#define B_SELECT_WRITE 2 -#define B_SELECT_EXCEPTION 3 - -extern void notify_select_event(selectsync * sync, uint32 ref); - #define SHOW_INSANE_DEBUGGING (1) #define SERIAL_DEBUGGING (0) /* Force the driver to stay loaded in memory */ @@ -59,7 +52,11 @@ extern void notify_select_event(selectsync * sync, uint32 ref); #define ERR "ERROR: " #endif -typedef void (*notify_select_event_function)(selectsync * sync, uint32 ref); +#ifdef COMPILE_FOR_R5 + typedef status_t (*notify_select_event_function)(selectsync * sync, uint32 ref); +#else + typedef status_t (*notify_select_event_function)(selectsync * sync, uint32 ref, uint8 event); +#endif struct socket; /* forward declaration */ @@ -86,7 +83,7 @@ typedef struct { /* to unload the driver, simply write UNLOAD_CMD to him: * $ echo stop > /dev/net/stack * As soon as last app, via libnet.so, stop using it, it will unload, - * and in turn stop the stack and unload all kernel modules... + * and in turn stop the stack and unload all network kernel modules... */ #define UNLOAD_CMD "stop" #endif @@ -105,7 +102,7 @@ static status_t net_stack_deselect(void *cookie, uint8 event, selectsync *sync); /* Privates prototypes */ static void on_socket_event(void * socket, uint32 event, void * cookie); -static void r5_notify_select_event(selectsync * sync, uint32 ref); +static status_t r5_notify_select_event(selectsync * sync, uint32 ref, uint8 event); #if STAY_LOADED static status_t keep_driver_loaded(); @@ -455,13 +452,13 @@ static status_t net_stack_control(void *cookie, uint32 op, void *data, size_t le case B_SET_BLOCKING_IO: { int off = false; nsc->open_flags &= ~O_NONBLOCK; - return core->socket_ioctl(nsc->socket, FIONBIO, &off); + return core->socket_ioctl(nsc->socket, FIONBIO, (caddr_t) &off); } case B_SET_NONBLOCKING_IO: { int on = true; nsc->open_flags |= O_NONBLOCK; - return core->socket_ioctl(nsc->socket, FIONBIO, &on); + return core->socket_ioctl(nsc->socket, FIONBIO, (caddr_t) &on); } case NET_STACK_SELECT: @@ -685,11 +682,15 @@ static void on_socket_event(void * socket, uint32 event, void * cookie) s = nsc->selecters; while (s) { if (s->event == event) + // notify this selecter (thread/event pair) +#ifdef COMPILRE_FOR_R5 s->notify(s->sync, s->ref); - // notify this selecter (thread/event pair) +#else + s->notify(s->sync, s->ref, event); +#endif s = s->next; }; - + // unlock the selecters list release_sem(nsc->selecters_lock); return; @@ -701,14 +702,14 @@ static void on_socket_event(void * socket, uint32 event, void * cookie) So, here is our own notify_select_event() implementation, the driver-side pair of the our libnet.so select() implementation... */ -static void r5_notify_select_event(selectsync * sync, uint32 ref) +static status_t r5_notify_select_event(selectsync * sync, uint32 ref, uint8 event) { area_id area; struct r5_selectsync * rss; int fd; #if SHOW_INSANE_DEBUGGING - dprintf(LOGID "r5_notify_select_event(%p, %ld)\n", sync, ref); + dprintf(LOGID "r5_notify_select_event(%p, %ld, %d)\n", sync, ref, event); #endif rss = NULL; @@ -718,7 +719,7 @@ static void r5_notify_select_event(selectsync * sync, uint32 ref) #if SHOW_INSANE_DEBUGGING dprintf(LOGID "r5_notify_select_event: clone_area(%d) failed -> %d!\n", (int) sync, (int) area); #endif - return; + return area; }; #if SHOW_INSANE_DEBUGGING @@ -732,14 +733,14 @@ static void r5_notify_select_event(selectsync * sync, uint32 ref) goto error; fd = ref >> 8; - switch (ref & 0xFF) { + switch (ref & 0xFF) { // event == ref & 0xFF case B_SELECT_READ: FD_SET(fd, &rss->rbits); break; case B_SELECT_WRITE: FD_SET(fd, &rss->wbits); break; - case B_SELECT_EXCEPTION: + case B_SELECT_ERROR: FD_SET(fd, &rss->ebits); break; }; @@ -747,10 +748,12 @@ static void r5_notify_select_event(selectsync * sync, uint32 ref) // wakeup select() release_sem(rss->wakeup); - release_sem(rss->lock); + release_sem(rss->lock); + return B_OK; error: delete_area(area); + return B_ERROR; }