NewOS read/write hooks return ssize_t, but on BeOS, they return status_t and
the number of bytes read/written in an argument. Until now, we had a buggy mix between those two solutions. Courtesy of Jack Burton. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7102 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -124,21 +124,21 @@ static status_t
|
|||||||
mouse_open(const char *name, uint32 flags, void **cookie)
|
mouse_open(const char *name, uint32 flags, void **cookie)
|
||||||
{
|
{
|
||||||
*cookie = NULL;
|
*cookie = NULL;
|
||||||
return 0;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static status_t
|
static status_t
|
||||||
mouse_close(void * cookie)
|
mouse_close(void * cookie)
|
||||||
{
|
{
|
||||||
return 0;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static status_t
|
static status_t
|
||||||
mouse_freecookie(void * cookie)
|
mouse_freecookie(void * cookie)
|
||||||
{
|
{
|
||||||
return 0;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -150,23 +150,23 @@ mouse_freecookie(void * cookie)
|
|||||||
* len, buffer size, must be at least the size of the data packet
|
* len, buffer size, must be at least the size of the data packet
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static ssize_t
|
static status_t
|
||||||
mouse_read(void *cookie, off_t pos, void *buf, size_t *len)
|
mouse_read(void *cookie, off_t pos, void *buf, size_t *len)
|
||||||
{
|
{
|
||||||
// inform interrupt handler that data is being waited for
|
// inform interrupt handler that data is being waited for
|
||||||
in_read = true;
|
in_read = true;
|
||||||
|
|
||||||
// wait until there is data to read
|
// wait until there is data to read
|
||||||
if(acquire_sem_etc(mouse_sem, 1, B_CAN_INTERRUPT, 0) ==
|
if (acquire_sem_etc(mouse_sem, 1, B_CAN_INTERRUPT, 0) == B_INTERRUPTED) {
|
||||||
EINTR) {
|
*len = 0;
|
||||||
return 0;
|
return B_OK;
|
||||||
} // if
|
}
|
||||||
|
|
||||||
// verify user's buffer is of the right size
|
// verify user's buffer is of the right size
|
||||||
if (*len < PACKET_SIZE) {
|
if (*len < PACKET_SIZE) {
|
||||||
*len = 0;
|
*len = 0;
|
||||||
/* XXX - should return an error here */
|
/* XXX - should return an error here */
|
||||||
return 0;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy data to user's buffer
|
// copy data to user's buffer
|
||||||
@@ -175,11 +175,11 @@ mouse_read(void *cookie, off_t pos, void *buf, size_t *len)
|
|||||||
((char*)buf)[2] = md_read.delta_y;
|
((char*)buf)[2] = md_read.delta_y;
|
||||||
|
|
||||||
*len = PACKET_SIZE;
|
*len = PACKET_SIZE;
|
||||||
return 0;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static ssize_t
|
static status_t
|
||||||
mouse_write(void * cookie, off_t pos, const void *buf, size_t *len)
|
mouse_write(void * cookie, off_t pos, const void *buf, size_t *len)
|
||||||
{
|
{
|
||||||
*len = 0;
|
*len = 0;
|
||||||
|
|||||||
@@ -33,8 +33,8 @@ static const char *sRandomNames[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static status_t random_open(const char *name, uint32 flags, void **cookie);
|
static status_t random_open(const char *name, uint32 flags, void **cookie);
|
||||||
static ssize_t random_read(void *cookie, off_t position, void *_buffer, size_t *_numBytes);
|
static status_t random_read(void *cookie, off_t position, void *_buffer, size_t *_numBytes);
|
||||||
static ssize_t random_write(void *cookie, off_t position, const void *buffer, size_t *_numBytes);
|
static status_t random_write(void *cookie, off_t position, const void *buffer, size_t *_numBytes);
|
||||||
static status_t random_control(void *cookie, uint32 op, void *arg, size_t length);
|
static status_t random_control(void *cookie, uint32 op, void *arg, size_t length);
|
||||||
static status_t random_close(void *cookie);
|
static status_t random_close(void *cookie);
|
||||||
static status_t random_free(void *cookie);
|
static status_t random_free(void *cookie);
|
||||||
@@ -353,6 +353,7 @@ publish_devices(void)
|
|||||||
return sRandomNames;
|
return sRandomNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
device_hooks *
|
device_hooks *
|
||||||
find_device(const char* name)
|
find_device(const char* name)
|
||||||
{
|
{
|
||||||
@@ -388,7 +389,7 @@ random_open(const char *name, uint32 flags, void **cookie)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static ssize_t
|
static status_t
|
||||||
random_read(void *cookie, off_t position, void *_buffer, size_t *_numBytes)
|
random_read(void *cookie, off_t position, void *_buffer, size_t *_numBytes)
|
||||||
{
|
{
|
||||||
int32 *buffer = (int32 *)_buffer;
|
int32 *buffer = (int32 *)_buffer;
|
||||||
@@ -413,11 +414,12 @@ random_read(void *cookie, off_t position, void *_buffer, size_t *_numBytes)
|
|||||||
buffer8[(i*4) + j] = chrand8(sRandomEnv);
|
buffer8[(i*4) + j] = chrand8(sRandomEnv);
|
||||||
|
|
||||||
release_sem(sRandomSem);
|
release_sem(sRandomSem);
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static ssize_t
|
static status_t
|
||||||
random_write(void *cookie, off_t position, const void *buffer, size_t *_numBytes)
|
random_write(void *cookie, off_t position, const void *buffer, size_t *_numBytes)
|
||||||
{
|
{
|
||||||
return B_OK;
|
return B_OK;
|
||||||
|
|||||||
Reference in New Issue
Block a user