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
This commit is contained in:
Philippe Houdoin
2004-10-03 15:10:25 +00:00
parent 0bba897b1e
commit 8a3c512516
2 changed files with 47 additions and 41 deletions
@@ -15,13 +15,13 @@
#else #else
// Public includes // Public includes
#include <stdlib.h>
#include <string.h>
#include <drivers/Drivers.h> #include <drivers/Drivers.h>
#include <drivers/KernelExport.h> #include <drivers/KernelExport.h>
#include <driver_settings.h> #include <driver_settings.h>
// Posix includes
#include <malloc.h>
#include <string.h>
#include <netinet/in_var.h> #include <netinet/in_var.h>
// Private includes // Private includes
@@ -30,13 +30,6 @@
#include <userland_ipc.h> #include <userland_ipc.h>
#include <sys/sockio.h> #include <sys/sockio.h>
/* 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 // Debug output
//*****************************************************/ //*****************************************************/
@@ -79,7 +72,12 @@ extern void notify_select_event(selectsync * sync, uint32 ref);
/* wait one second when waiting on the stack */ /* wait one second when waiting on the stack */
#define STACK_TIMEOUT 1000000LL #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 // this struct will store one select() event to monitor per thread
typedef struct selecter { typedef struct selecter {
@@ -127,7 +125,7 @@ static status_t net_server_deselect(void *cookie, uint8 event, selectsync *sync)
/* select() support */ /* select() support */
static int32 socket_event_listener(void *data); static int32 socket_event_listener(void *data);
static void on_socket_event(void *socket, uint32 event, void *cookie); 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 */ /* command queue */
static status_t init_connection(void **cookie); static status_t init_connection(void **cookie);
@@ -517,7 +515,11 @@ static void on_socket_event(void *socket, uint32 event, void *cookie)
while (s) { while (s) {
if (s->event == event) if (s->event == event)
// notify this selecter (thread/event pair) // notify this selecter (thread/event pair)
#ifdef COMPILE_FOR_R5
g_nse(s->sync, s->ref); g_nse(s->sync, s->ref);
#else
g_nse(s->sync, s->ref, (uint8) event);
#endif
s = s->next; 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 So, here is our own notify_select_event() implementation, the driver-side pair
of the our libnet.so select() implementation... 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; area_id area;
struct r5_selectsync *rss; struct r5_selectsync *rss;
@@ -548,7 +550,7 @@ static void r5_notify_select_event(selectsync *sync, uint32 ref)
#if SHOW_INSANE_DEBUGGING #if SHOW_INSANE_DEBUGGING
dprintf(LOGID "r5_notify_select_event: clone_area(%d) failed -> %d!\n", (area_id) sync, area); dprintf(LOGID "r5_notify_select_event: clone_area(%d) failed -> %d!\n", (area_id) sync, area);
#endif #endif
return; return area;
}; };
#if SHOW_INSANE_DEBUGGING #if SHOW_INSANE_DEBUGGING
@@ -562,14 +564,14 @@ static void r5_notify_select_event(selectsync *sync, uint32 ref)
goto error; goto error;
fd = ref >> 8; fd = ref >> 8;
switch (ref & 0xFF) { switch (ref & 0xFF) { // event == ref & 0xFF !
case B_SELECT_READ: case B_SELECT_READ:
FD_SET(fd, &rss->rbits); FD_SET(fd, &rss->rbits);
break; break;
case B_SELECT_WRITE: case B_SELECT_WRITE:
FD_SET(fd, &rss->wbits); FD_SET(fd, &rss->wbits);
break; break;
case B_SELECT_EXCEPTION: case B_SELECT_ERROR:
FD_SET(fd, &rss->ebits); FD_SET(fd, &rss->ebits);
break; break;
}; };
@@ -581,6 +583,7 @@ static void r5_notify_select_event(selectsync *sync, uint32 ref)
error: error:
delete_area(area); delete_area(area);
return B_ERROR;
} }
@@ -1,7 +1,7 @@
/* net_stack_driver.c /* net_stack_driver.c
* *
* This file implements a very simple socket driver that is intended to * 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 #ifndef _KERNEL_MODE
@@ -11,28 +11,21 @@
#else #else
// Public/system includes // Public/system includes
#include <stdlib.h>
#include <string.h>
#include <drivers/Drivers.h> #include <drivers/Drivers.h>
#include <drivers/KernelExport.h> #include <drivers/KernelExport.h>
#include <drivers/driver_settings.h> #include <drivers/driver_settings.h>
#include <drivers/module.h> // For get_module()/put_module() #include <drivers/module.h> // For get_module()/put_module()
#include <net_stack_driver.h>
#include <netinet/in_var.h> #include <netinet/in_var.h>
#include <stdlib.h>
#include <string.h>
// Private includes // Private includes
#include <net_stack_driver.h>
#include <sys/protosw.h> #include <sys/protosw.h>
#include <core_module.h> #include <core_module.h>
/* 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 SHOW_INSANE_DEBUGGING (1)
#define SERIAL_DEBUGGING (0) #define SERIAL_DEBUGGING (0)
/* Force the driver to stay loaded in memory */ /* Force the driver to stay loaded in memory */
@@ -59,7 +52,11 @@ extern void notify_select_event(selectsync * sync, uint32 ref);
#define ERR "ERROR: " #define ERR "ERROR: "
#endif #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 */ struct socket; /* forward declaration */
@@ -86,7 +83,7 @@ typedef struct {
/* to unload the driver, simply write UNLOAD_CMD to him: /* to unload the driver, simply write UNLOAD_CMD to him:
* $ echo stop > /dev/net/stack * $ echo stop > /dev/net/stack
* As soon as last app, via libnet.so, stop using it, it will unload, * 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" #define UNLOAD_CMD "stop"
#endif #endif
@@ -105,7 +102,7 @@ static status_t net_stack_deselect(void *cookie, uint8 event, selectsync *sync);
/* Privates prototypes */ /* Privates prototypes */
static void on_socket_event(void * socket, uint32 event, void * cookie); 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 #if STAY_LOADED
static status_t keep_driver_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: { case B_SET_BLOCKING_IO: {
int off = false; int off = false;
nsc->open_flags &= ~O_NONBLOCK; 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: { case B_SET_NONBLOCKING_IO: {
int on = true; int on = true;
nsc->open_flags |= O_NONBLOCK; 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: case NET_STACK_SELECT:
@@ -685,11 +682,15 @@ static void on_socket_event(void * socket, uint32 event, void * cookie)
s = nsc->selecters; s = nsc->selecters;
while (s) { while (s) {
if (s->event == event) if (s->event == event)
// notify this selecter (thread/event pair)
#ifdef COMPILRE_FOR_R5
s->notify(s->sync, s->ref); s->notify(s->sync, s->ref);
// notify this selecter (thread/event pair) #else
s->notify(s->sync, s->ref, event);
#endif
s = s->next; s = s->next;
}; };
// unlock the selecters list // unlock the selecters list
release_sem(nsc->selecters_lock); release_sem(nsc->selecters_lock);
return; 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 So, here is our own notify_select_event() implementation, the driver-side pair
of the our libnet.so select() implementation... 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; area_id area;
struct r5_selectsync * rss; struct r5_selectsync * rss;
int fd; int fd;
#if SHOW_INSANE_DEBUGGING #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 #endif
rss = NULL; rss = NULL;
@@ -718,7 +719,7 @@ static void r5_notify_select_event(selectsync * sync, uint32 ref)
#if SHOW_INSANE_DEBUGGING #if SHOW_INSANE_DEBUGGING
dprintf(LOGID "r5_notify_select_event: clone_area(%d) failed -> %d!\n", (int) sync, (int) area); dprintf(LOGID "r5_notify_select_event: clone_area(%d) failed -> %d!\n", (int) sync, (int) area);
#endif #endif
return; return area;
}; };
#if SHOW_INSANE_DEBUGGING #if SHOW_INSANE_DEBUGGING
@@ -732,14 +733,14 @@ static void r5_notify_select_event(selectsync * sync, uint32 ref)
goto error; goto error;
fd = ref >> 8; fd = ref >> 8;
switch (ref & 0xFF) { switch (ref & 0xFF) { // event == ref & 0xFF
case B_SELECT_READ: case B_SELECT_READ:
FD_SET(fd, &rss->rbits); FD_SET(fd, &rss->rbits);
break; break;
case B_SELECT_WRITE: case B_SELECT_WRITE:
FD_SET(fd, &rss->wbits); FD_SET(fd, &rss->wbits);
break; break;
case B_SELECT_EXCEPTION: case B_SELECT_ERROR:
FD_SET(fd, &rss->ebits); FD_SET(fd, &rss->ebits);
break; break;
}; };
@@ -747,10 +748,12 @@ static void r5_notify_select_event(selectsync * sync, uint32 ref)
// wakeup select() // wakeup select()
release_sem(rss->wakeup); release_sem(rss->wakeup);
release_sem(rss->lock); release_sem(rss->lock);
return B_OK;
error: error:
delete_area(area); delete_area(area);
return B_ERROR;
} }