瀏覽代碼

faux.eloop: Change typedef for callback prototype

Serj Kalichev 3 年之前
父節點
當前提交
0720e2a615
共有 3 個文件被更改,包括 20 次插入20 次删除
  1. 8 8
      faux/eloop.h
  2. 10 10
      faux/eloop/eloop.c
  3. 2 2
      faux/eloop/private.h

+ 8 - 8
faux/eloop.h

@@ -30,30 +30,30 @@ typedef struct {
 } faux_eloop_info_signal_t;
 
 // Callback function prototype
-typedef bool_t faux_eloop_cb_f(faux_eloop_t *eloop, faux_eloop_type_e type,
+typedef bool_t (*faux_eloop_cb_f)(faux_eloop_t *eloop, faux_eloop_type_e type,
 	void *associated_data, void *user_data);
 
 
 C_DECL_BEGIN
 
-faux_eloop_t *faux_eloop_new(faux_eloop_cb_f *default_event_cb);
+faux_eloop_t *faux_eloop_new(faux_eloop_cb_f default_event_cb);
 void faux_eloop_free(faux_eloop_t *eloop);
 bool_t faux_eloop_loop(faux_eloop_t *eloop);
 bool_t faux_eloop_add_fd(faux_eloop_t *eloop, int fd, short events,
-	faux_eloop_cb_f *event_cb, void *user_data);
+	faux_eloop_cb_f event_cb, void *user_data);
 bool_t faux_eloop_del_fd(faux_eloop_t *eloop, int fd);
 bool_t faux_eloop_add_signal(faux_eloop_t *eloop, int signo,
-	faux_eloop_cb_f *event_cb, void *user_data);
+	faux_eloop_cb_f event_cb, void *user_data);
 bool_t faux_eloop_del_signal(faux_eloop_t *eloop, int signo);
 bool_t faux_eloop_add_sched_once(faux_eloop_t *eloop, const struct timespec *time,
-	int ev_id, faux_eloop_cb_f *event_cb, void *data);
+	int ev_id, faux_eloop_cb_f event_cb, void *data);
 bool_t faux_eloop_add_sched_once_delayed(faux_eloop_t *eloop, const struct timespec *interval,
-	int ev_id, faux_eloop_cb_f *event_cb, void *data);
+	int ev_id, faux_eloop_cb_f event_cb, void *data);
 bool_t faux_eloop_add_sched_periodic(faux_eloop_t *eloop, const struct timespec *time,
-	int ev_id, faux_eloop_cb_f *event_cb, void *data,
+	int ev_id, faux_eloop_cb_f event_cb, void *data,
 	const struct timespec *period, unsigned int cycle_num);
 bool_t faux_eloop_add_sched_periodic_delayed(faux_eloop_t *eloop,
-	int ev_id, faux_eloop_cb_f *event_cb, void *data,
+	int ev_id, faux_eloop_cb_f event_cb, void *data,
 	const struct timespec *period, unsigned int cycle_num);
 bool_t faux_eloop_del_sched(faux_eloop_t *eloop, int id);
 

+ 10 - 10
faux/eloop/eloop.c

@@ -86,7 +86,7 @@ static int faux_eloop_signal_kcompare(const void *key, const void *list_item)
 }
 
 
-faux_eloop_t *faux_eloop_new(faux_eloop_cb_f *default_event_cb)
+faux_eloop_t *faux_eloop_new(faux_eloop_cb_f default_event_cb)
 {
 	faux_eloop_t *eloop = NULL;
 
@@ -242,7 +242,7 @@ bool_t faux_eloop_loop(faux_eloop_t *eloop)
 			// Some scheduled events
 			while(faux_sched_pop(eloop->sched, &ev_id, (void **)&context) == 0) {
 				faux_eloop_info_sched_t info = {};
-				faux_eloop_cb_f *event_cb = NULL;
+				faux_eloop_cb_f event_cb = NULL;
 				bool_t r = BOOL_TRUE;
 
 				event_cb = context->event_cb;
@@ -272,7 +272,7 @@ bool_t faux_eloop_loop(faux_eloop_t *eloop)
 		while ((pollfd = faux_pollfd_each_active(eloop->pollfds, &pollfd_iter))) {
 			int fd = pollfd->fd;
 			faux_eloop_info_fd_t info = {};
-			faux_eloop_cb_f *event_cb = NULL;
+			faux_eloop_cb_f event_cb = NULL;
 			faux_eloop_fd_t *entry = NULL;
 			bool_t r = BOOL_TRUE;
 
@@ -367,7 +367,7 @@ bool_t faux_eloop_loop(faux_eloop_t *eloop)
 
 
 bool_t faux_eloop_add_fd(faux_eloop_t *eloop, int fd, short events,
-	faux_eloop_cb_f *event_cb, void *user_data)
+	faux_eloop_cb_f event_cb, void *user_data)
 {
 	faux_eloop_fd_t *entry = NULL;
 	faux_list_node_t *new_node = NULL;
@@ -414,7 +414,7 @@ bool_t faux_eloop_del_fd(faux_eloop_t *eloop, int fd)
 
 
 bool_t faux_eloop_add_signal(faux_eloop_t *eloop, int signo,
-	faux_eloop_cb_f *event_cb, void *user_data)
+	faux_eloop_cb_f event_cb, void *user_data)
 {
 	faux_eloop_signal_t *entry = NULL;
 
@@ -496,7 +496,7 @@ bool_t faux_eloop_del_signal(faux_eloop_t *eloop, int signo)
 
 
 static faux_eloop_context_t *faux_eloop_new_context(
-	faux_eloop_cb_f *event_cb, void *data)
+	faux_eloop_cb_f event_cb, void *data)
 {
 	faux_eloop_context_t *context = NULL;
 
@@ -513,7 +513,7 @@ static faux_eloop_context_t *faux_eloop_new_context(
 
 
 bool_t faux_eloop_add_sched_once(faux_eloop_t *eloop, const struct timespec *time,
-	int ev_id, faux_eloop_cb_f *event_cb, void *data)
+	int ev_id, faux_eloop_cb_f event_cb, void *data)
 {
 	faux_eloop_context_t *context = NULL;
 
@@ -539,7 +539,7 @@ bool_t faux_eloop_add_sched_once(faux_eloop_t *eloop, const struct timespec *tim
 
 
 bool_t faux_eloop_add_sched_once_delayed(faux_eloop_t *eloop, const struct timespec *interval,
-	int ev_id, faux_eloop_cb_f *event_cb, void *data)
+	int ev_id, faux_eloop_cb_f event_cb, void *data)
 {
 	faux_eloop_context_t *context = NULL;
 
@@ -565,7 +565,7 @@ bool_t faux_eloop_add_sched_once_delayed(faux_eloop_t *eloop, const struct times
 
 
 bool_t faux_eloop_add_sched_periodic(faux_eloop_t *eloop, const struct timespec *time,
-	int ev_id, faux_eloop_cb_f *event_cb, void *data,
+	int ev_id, faux_eloop_cb_f event_cb, void *data,
 	const struct timespec *period, unsigned int cycle_num)
 {
 	faux_eloop_context_t *context = NULL;
@@ -593,7 +593,7 @@ bool_t faux_eloop_add_sched_periodic(faux_eloop_t *eloop, const struct timespec
 
 
 bool_t faux_eloop_add_sched_periodic_delayed(faux_eloop_t *eloop,
-	int ev_id, faux_eloop_cb_f *event_cb, void *data,
+	int ev_id, faux_eloop_cb_f event_cb, void *data,
 	const struct timespec *period, unsigned int cycle_num)
 {
 	faux_eloop_context_t *context = NULL;

+ 2 - 2
faux/eloop/private.h

@@ -7,7 +7,7 @@
 
 struct faux_eloop_s {
 	bool_t working; // Is event loop active now. Can detect nested loop.
-	faux_eloop_cb_f *default_event_cb; // Default callback function
+	faux_eloop_cb_f default_event_cb; // Default callback function
 	faux_sched_t *sched; // Service shed structure
 	faux_list_t *fds; // List of registered file descriptors
 	faux_pollfd_t *pollfds; // Service object for ppoll()
@@ -21,7 +21,7 @@ struct faux_eloop_s {
 
 
 typedef struct faux_eloop_context_s {
-	faux_eloop_cb_f *event_cb;
+	faux_eloop_cb_f event_cb;
 	void *user_data;
 } faux_eloop_context_t;