Archived
3
0

libipc now uses 64-bit float (double) timers.

This commit is contained in:
Karchnu 2020-06-12 02:09:46 +02:00
parent 290a693572
commit 062c36a2f3
5 changed files with 23 additions and 22 deletions

View File

@ -1,5 +1,5 @@
PACKAGE = 'libipc'
VERSION = '0.5.1'
VERSION = '0.6.0'
PREFIX := /usr/local
BINDIR := $(PREFIX)/bin
@ -50,25 +50,25 @@ libipc.so: src/communication.o src/error.o src/fs.o src/message.o src/network.o
$(Q)$(CC) -o libipc.so -shared $(LDFLAGS) src/communication.o src/error.o src/fs.o src/message.o src/network.o src/print.o src/usocket.o src/utils.o
libipc.so.install: libipc.so
@echo ' IN > $(LIBDIR)/libipc.so.0.5.1'
@echo ' IN > $(LIBDIR)/libipc.so.0.6.0'
$(Q)mkdir -p '$(DESTDIR)$(LIBDIR)'
$(Q)install -m0755 libipc.so $(DESTDIR)$(LIBDIR)/libipc.so.0.5.1
@echo ' LN > $(LIBDIR)/libipc.so.0.5'
$(Q)ln -sf '$(LIBDIR)/libipc.so.0.5.1' '$(DESTDIR)/$(LIBDIR)/libipc.so.0.5'
$(Q)install -m0755 libipc.so $(DESTDIR)$(LIBDIR)/libipc.so.0.6.0
@echo ' LN > $(LIBDIR)/libipc.so.0.6'
$(Q)ln -sf '$(LIBDIR)/libipc.so.0.6.0' '$(DESTDIR)/$(LIBDIR)/libipc.so.0.6'
@echo ' LN > $(LIBDIR)/libipc.so.0'
$(Q)ln -sf '$(LIBDIR)/libipc.so.0.5.1' '$(DESTDIR)/$(LIBDIR)/libipc.so.0'
$(Q)ln -sf '$(LIBDIR)/libipc.so.0.6.0' '$(DESTDIR)/$(LIBDIR)/libipc.so.0'
@echo ' LN > $(LIBDIR)/libipc.so'
$(Q)ln -sf '$(LIBDIR)/libipc.so.0.5.1' '$(DESTDIR)/$(LIBDIR)/libipc.so'
$(Q)ln -sf '$(LIBDIR)/libipc.so.0.6.0' '$(DESTDIR)/$(LIBDIR)/libipc.so'
libipc.so.clean:
@echo ' RM > libipc.so'
$(Q)rm -f libipc.so
libipc.so.uninstall:
@echo ' RM > $(LIBDIR)/libipc.so.0.5.1'
$(Q)rm -f '$(DESTDIR)$(LIBDIR)/libipc.so.0.5.1'
@echo ' RM > $(LIBDIR)/libipc.so.0.5'
$(Q)rm -f '$(DESTDIR)$(LIBDIR)/libipc.so.0.5'
@echo ' RM > $(LIBDIR)/libipc.so.0.6.0'
$(Q)rm -f '$(DESTDIR)$(LIBDIR)/libipc.so.0.6.0'
@echo ' RM > $(LIBDIR)/libipc.so.0.6'
$(Q)rm -f '$(DESTDIR)$(LIBDIR)/libipc.so.0.6'
@echo ' RM > $(LIBDIR)/libipc.so.0'
$(Q)rm -f '$(DESTDIR)$(LIBDIR)/libipc.so.0'
@echo ' RM > $(LIBDIR)/libipc.so'
@ -297,7 +297,7 @@ $(PACKAGE)-$(VERSION).tar.bz2: distdir
$(PACKAGE)-$(VERSION)/src/utils.h
help:
@echo ' :: libipc-0.5.1'
@echo ' :: libipc-0.6.0'
@echo ''
@echo 'Generic targets:'
@echo ' - help  Prints this help message.'

View File

@ -21,8 +21,8 @@ struct ipc_connection_infos *clients = NULL;
void main_loop ()
{
long base_timer = 0;
long timer = base_timer;
double base_timer = 0;
double timer = base_timer;
SECURE_DECLARATION (struct ipc_error, ret);
clients = malloc (sizeof (struct ipc_connection_infos));

View File

@ -1,6 +1,6 @@
package=libipc # Package name.
version=0.5.1 # Package version.
version=0.6.0 # Package version.
# Our targets are the library and its documentation.
targets=(libipc man/libipc.7)

View File

@ -368,7 +368,7 @@ struct ipc_error handle_message (struct ipc_event *event, struct ipc_connection_
struct ipc_error ipc_wait_event_networkd (struct ipc_connection_infos *cinfos
, struct ipc_connection_info *cinfo // NULL for clients
, struct ipc_event *event, struct ipc_switchings *switchdb
, long *timer)
, double *timer)
{
T_R ((cinfos == NULL), IPC_ERROR_WAIT_EVENT__NO_CLIENTS_PARAM);
T_R ((event == NULL), IPC_ERROR_WAIT_EVENT__NO_EVENT_PARAM);
@ -410,15 +410,16 @@ struct ipc_error ipc_wait_event_networkd (struct ipc_connection_infos *cinfos
struct timeval *ptimeout = NULL;
SECURE_DECLARATION (struct timeval, timeout);
if (timer != NULL && *timer > 0) {
timeout.tv_sec = *timer;
if (timer != NULL && *timer > 0.0) {
timeout.tv_sec = (long) *timer;
timeout.tv_usec = (long) ((long)((*timer) * 1000000) % 1000000);
ptimeout = &timeout;
}
T_PERROR_RIPC ((select (fdmax + 1, &readf, NULL, NULL, ptimeout) == -1), "select", IPC_ERROR_WAIT_EVENT__SELECT);
if (ptimeout != NULL) {
*timer = timeout.tv_sec;
*timer = (double) timeout.tv_sec + (timeout.tv_usec / 1000000.0);
if (*timer == 0) {
IPC_EVENT_SET (event, IPC_EVENT_TYPE_TIMER, NULL, NULL);
IPC_RETURN_NO_ERROR;
@ -444,7 +445,7 @@ struct ipc_error ipc_wait_event_networkd (struct ipc_connection_infos *cinfos
struct ipc_error ipc_wait_event (struct ipc_connection_infos *cinfos
, struct ipc_connection_info *cinfo // NULL for clients
, struct ipc_event *event, long *timer)
, struct ipc_event *event, double *timer)
{
return ipc_wait_event_networkd (cinfos, cinfo, event, NULL, timer);
}

View File

@ -251,7 +251,7 @@ struct ipc_error ipc_write (const struct ipc_connection_info *, const struct ipc
struct ipc_error ipc_wait_event (struct ipc_connection_infos *clients
, struct ipc_connection_info *srv
, struct ipc_event *event, long *timer);
, struct ipc_event *event, double *timer);
// store and remove only pointers on allocated structures
struct ipc_error ipc_add (struct ipc_connection_infos *, struct ipc_connection_info *);
@ -324,7 +324,7 @@ struct networkd {
struct ipc_error ipc_wait_event_networkd (struct ipc_connection_infos *cinfos
, struct ipc_connection_info *cinfo // cinfo is NULL for clients
, struct ipc_event *event, struct ipc_switchings *switchdb, long *timer);
, struct ipc_event *event, struct ipc_switchings *switchdb, double *timer);
void ipc_switching_add (struct ipc_switchings *is, int orig, int dest);
int ipc_switching_del (struct ipc_switchings *is, int fd);