From bbaf63c7fdfcce03bea7790d3107c6706442a81d Mon Sep 17 00:00:00 2001 From: leitner Date: Thu, 14 May 2020 14:46:31 +0000 Subject: [PATCH] remove compiler warnings in ent try to fix io_waituntil2 on freebsd --- ent.c | 12 +++++++----- io/io_waituntil2.c | 15 ++++++++++++++- scan/scan_ulongn.c | 2 ++ 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/ent.c b/ent.c index 6774b2b..848d84a 100644 --- a/ent.c +++ b/ent.c @@ -5,6 +5,7 @@ #include "scan.h" #include +#define INTERNAL #include "scan/scan_ulong.c" #include "scan/scan_ulongn.c" #include "fmt/fmt_utf8.c" @@ -23,7 +24,7 @@ struct entity { }* root,** cur=&root; struct letter { - char c; + unsigned char c; struct letters* weiter; uint32_t marshaled; // lower 8 bits: char. rest: ofs from start of marshaled blob }; @@ -126,14 +127,14 @@ void marshalhelper(struct letters* s) { } void marshal(struct letters* s) { - fprintf(stderr,"nodes=%lu, datasize=%lu\n",nodes,datasize); + fprintf(stderr,"nodes=%zu, datasize=%zu\n",nodes,datasize); heap=malloc((nodes+1)*sizeof(uint32_t)+datasize); if (!heap) nomem(); marshaled=(uint32_t*)heap; marshaled[0]=nodes+1; data=heap+(nodes+1)*sizeof(uint32_t); marshalhelper(s); - fprintf(stderr,"actually used: %lu nodes, %lu bytes data\n",used,useddata); + fprintf(stderr,"actually used: %zu nodes, %zu bytes data\n",used,useddata); } char* lookup(char* ds,size_t ofs,const char* t) { @@ -168,7 +169,8 @@ int main() { if (!(*s=='"')) continue; ++s; entity=s; - if (*entity!='&') continue; ++entity; ++s; + if (*entity!='&') continue; + ++entity; ++s; for (; *s && *s!='"'; ++s) ; // skip to end of entity if (!(*s=='"')) continue; if (s[-1]!=';') continue; @@ -216,7 +218,7 @@ int main() { { FILE* f=fopen("entities.h","w"); size_t i; - fprintf(f,"struct {\n uint32_t tab[%u];\n char data[%lu];\n} entities = {\n {",marshaled[0],datasize); + fprintf(f,"struct {\n uint32_t tab[%u];\n char data[%zu];\n} entities = {\n {",marshaled[0],datasize); for (i=0; i +#include #endif #ifndef EPOLLRDNORM @@ -132,7 +133,13 @@ int64 io_waituntil2(int64 milliseconds) { first_deferred=-1; // can't happen } } + /* if no interest in events has been registered, then return + * immediately */ if (!io_wanted_fds) return 0; + + /* only actually wait if all previous events have been dequeued */ + if (first_readable!=-1 || first_writeable!=-1) return 0; + #ifdef HAVE_EPOLL if (io_waitmode==EPOLL) { int n; @@ -261,11 +268,17 @@ int64 io_waituntil2(int64 milliseconds) { } if (!e->canread && (y[n].filter==EVFILT_READ)) { e->canread=1; +#ifdef DEBUG + assert(e->next_read==-1); +#endif e->next_read=first_readable; first_readable=y[n].ident; } - if (!e->canwrite && (y[n].filter==EVFILT_WRITE)) { + if ((y[n].filter==EVFILT_WRITE)) { e->canwrite=1; +#ifdef DEBUG + assert(e->next_write==-1); +#endif e->next_write=first_writeable; first_writeable=y[i].ident; } diff --git a/scan/scan_ulongn.c b/scan/scan_ulongn.c index ad45f65..3f08002 100644 --- a/scan/scan_ulongn.c +++ b/scan/scan_ulongn.c @@ -1,5 +1,7 @@ #include "scan.h" +#ifndef INTERNAL #include "haveuint128.h" +#endif size_t scan_ulongn(const char* src,size_t n,unsigned long int* dest) { register const char *tmp=src;