mirror of
https://github.com/X11Libre/xserver.git
synced 2026-03-24 03:44:06 +00:00
os: ospoll: use stdbool instead of X11's Bool
Low level OS specific code should not depend on higher level protocol headers. This also removes yet another conflict with win32/mingw headers. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
committed by
Enrico Weigelt
parent
91d20b0cb9
commit
d9db02d700
28
os/ospoll.c
28
os/ospoll.c
@@ -117,7 +117,7 @@ struct ospoll {
|
|||||||
struct ospollfd *osfds;
|
struct ospollfd *osfds;
|
||||||
int num;
|
int num;
|
||||||
int size;
|
int size;
|
||||||
Bool changed;
|
bool changed;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -271,7 +271,7 @@ ospoll_destroy(struct ospoll *ospoll)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
Bool
|
bool
|
||||||
ospoll_add(struct ospoll *ospoll, int fd,
|
ospoll_add(struct ospoll *ospoll, int fd,
|
||||||
enum ospoll_trigger trigger,
|
enum ospoll_trigger trigger,
|
||||||
void (*callback)(int fd, int xevents, void *data),
|
void (*callback)(int fd, int xevents, void *data),
|
||||||
@@ -286,7 +286,7 @@ ospoll_add(struct ospoll *ospoll, int fd,
|
|||||||
|
|
||||||
new_fds = realloc(ospoll->fds, new_size * sizeof (ospoll->fds[0]));
|
new_fds = realloc(ospoll->fds, new_size * sizeof (ospoll->fds[0]));
|
||||||
if (!new_fds)
|
if (!new_fds)
|
||||||
return FALSE;
|
return false;
|
||||||
ospoll->fds = new_fds;
|
ospoll->fds = new_fds;
|
||||||
ospoll->size = new_size;
|
ospoll->size = new_size;
|
||||||
}
|
}
|
||||||
@@ -308,7 +308,7 @@ ospoll_add(struct ospoll *ospoll, int fd,
|
|||||||
if (pos < 0) {
|
if (pos < 0) {
|
||||||
osfd = calloc(1, sizeof (struct ospollfd));
|
osfd = calloc(1, sizeof (struct ospollfd));
|
||||||
if (!osfd)
|
if (!osfd)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
if (ospoll->num >= ospoll->size) {
|
if (ospoll->num >= ospoll->size) {
|
||||||
struct ospollfd **new_fds;
|
struct ospollfd **new_fds;
|
||||||
@@ -317,7 +317,7 @@ ospoll_add(struct ospoll *ospoll, int fd,
|
|||||||
new_fds = realloc(ospoll->fds, new_size * sizeof (ospoll->fds[0]));
|
new_fds = realloc(ospoll->fds, new_size * sizeof (ospoll->fds[0]));
|
||||||
if (!new_fds) {
|
if (!new_fds) {
|
||||||
free (osfd);
|
free (osfd);
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
ospoll->fds = new_fds;
|
ospoll->fds = new_fds;
|
||||||
ospoll->size = new_size;
|
ospoll->size = new_size;
|
||||||
@@ -346,7 +346,7 @@ ospoll_add(struct ospoll *ospoll, int fd,
|
|||||||
|
|
||||||
osfd = calloc(1, sizeof (struct ospollfd));
|
osfd = calloc(1, sizeof (struct ospollfd));
|
||||||
if (!osfd)
|
if (!osfd)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
if (ospoll->num >= ospoll->size) {
|
if (ospoll->num >= ospoll->size) {
|
||||||
struct ospollfd **new_fds;
|
struct ospollfd **new_fds;
|
||||||
@@ -355,7 +355,7 @@ ospoll_add(struct ospoll *ospoll, int fd,
|
|||||||
new_fds = realloc(ospoll->fds, new_size * sizeof (ospoll->fds[0]));
|
new_fds = realloc(ospoll->fds, new_size * sizeof (ospoll->fds[0]));
|
||||||
if (!new_fds) {
|
if (!new_fds) {
|
||||||
free (osfd);
|
free (osfd);
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
ospoll->fds = new_fds;
|
ospoll->fds = new_fds;
|
||||||
ospoll->size = new_size;
|
ospoll->size = new_size;
|
||||||
@@ -367,7 +367,7 @@ ospoll_add(struct ospoll *ospoll, int fd,
|
|||||||
ev.events |= EPOLLET;
|
ev.events |= EPOLLET;
|
||||||
if (epoll_ctl(ospoll->epoll_fd, EPOLL_CTL_ADD, fd, &ev) == -1) {
|
if (epoll_ctl(ospoll->epoll_fd, EPOLL_CTL_ADD, fd, &ev) == -1) {
|
||||||
free(osfd);
|
free(osfd);
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
osfd->fd = fd;
|
osfd->fd = fd;
|
||||||
osfd->xevents = 0;
|
osfd->xevents = 0;
|
||||||
@@ -392,11 +392,11 @@ ospoll_add(struct ospoll *ospoll, int fd,
|
|||||||
|
|
||||||
new_fds = realloc(ospoll->fds, new_size * sizeof (ospoll->fds[0]));
|
new_fds = realloc(ospoll->fds, new_size * sizeof (ospoll->fds[0]));
|
||||||
if (!new_fds)
|
if (!new_fds)
|
||||||
return FALSE;
|
return false;
|
||||||
ospoll->fds = new_fds;
|
ospoll->fds = new_fds;
|
||||||
new_osfds = realloc(ospoll->osfds, new_size * sizeof (ospoll->osfds[0]));
|
new_osfds = realloc(ospoll->osfds, new_size * sizeof (ospoll->osfds[0]));
|
||||||
if (!new_osfds)
|
if (!new_osfds)
|
||||||
return FALSE;
|
return false;
|
||||||
ospoll->osfds = new_osfds;
|
ospoll->osfds = new_osfds;
|
||||||
ospoll->size = new_size;
|
ospoll->size = new_size;
|
||||||
}
|
}
|
||||||
@@ -404,7 +404,7 @@ ospoll_add(struct ospoll *ospoll, int fd,
|
|||||||
array_insert(ospoll->fds, ospoll->num, sizeof (ospoll->fds[0]), pos);
|
array_insert(ospoll->fds, ospoll->num, sizeof (ospoll->fds[0]), pos);
|
||||||
array_insert(ospoll->osfds, ospoll->num, sizeof (ospoll->osfds[0]), pos);
|
array_insert(ospoll->osfds, ospoll->num, sizeof (ospoll->osfds[0]), pos);
|
||||||
ospoll->num++;
|
ospoll->num++;
|
||||||
ospoll->changed = TRUE;
|
ospoll->changed = true;
|
||||||
|
|
||||||
ospoll->fds[pos].fd = fd;
|
ospoll->fds[pos].fd = fd;
|
||||||
ospoll->fds[pos].events = 0;
|
ospoll->fds[pos].events = 0;
|
||||||
@@ -415,7 +415,7 @@ ospoll_add(struct ospoll *ospoll, int fd,
|
|||||||
ospoll->osfds[pos].callback = callback;
|
ospoll->osfds[pos].callback = callback;
|
||||||
ospoll->osfds[pos].data = data;
|
ospoll->osfds[pos].data = data;
|
||||||
#endif
|
#endif
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -460,7 +460,7 @@ ospoll_remove(struct ospoll *ospoll, int fd)
|
|||||||
array_delete(ospoll->fds, ospoll->num, sizeof (ospoll->fds[0]), pos);
|
array_delete(ospoll->fds, ospoll->num, sizeof (ospoll->fds[0]), pos);
|
||||||
array_delete(ospoll->osfds, ospoll->num, sizeof (ospoll->osfds[0]), pos);
|
array_delete(ospoll->osfds, ospoll->num, sizeof (ospoll->osfds[0]), pos);
|
||||||
ospoll->num--;
|
ospoll->num--;
|
||||||
ospoll->changed = TRUE;
|
ospoll->changed = true;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -663,7 +663,7 @@ ospoll_wait(struct ospoll *ospoll, int timeout)
|
|||||||
#endif
|
#endif
|
||||||
#if POLL
|
#if POLL
|
||||||
nready = xserver_poll(ospoll->fds, ospoll->num, timeout);
|
nready = xserver_poll(ospoll->fds, ospoll->num, timeout);
|
||||||
ospoll->changed = FALSE;
|
ospoll->changed = false;
|
||||||
if (nready > 0) {
|
if (nready > 0) {
|
||||||
int f;
|
int f;
|
||||||
for (f = 0; f < ospoll->num; f++) {
|
for (f = 0; f < ospoll->num; f++) {
|
||||||
|
|||||||
@@ -23,6 +23,8 @@
|
|||||||
#ifndef _OSPOLL_H_
|
#ifndef _OSPOLL_H_
|
||||||
#define _OSPOLL_H_
|
#define _OSPOLL_H_
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
/* Forward declaration */
|
/* Forward declaration */
|
||||||
struct ospoll;
|
struct ospoll;
|
||||||
|
|
||||||
@@ -64,7 +66,7 @@ ospoll_destroy(struct ospoll *ospoll);
|
|||||||
* @param callback Function to call when triggered
|
* @param callback Function to call when triggered
|
||||||
* @param data Extra data to pass callback
|
* @param data Extra data to pass callback
|
||||||
*/
|
*/
|
||||||
Bool
|
bool
|
||||||
ospoll_add(struct ospoll *ospoll, int fd,
|
ospoll_add(struct ospoll *ospoll, int fd,
|
||||||
enum ospoll_trigger trigger,
|
enum ospoll_trigger trigger,
|
||||||
void (*callback)(int fd, int xevents, void *data),
|
void (*callback)(int fd, int xevents, void *data),
|
||||||
|
|||||||
Reference in New Issue
Block a user