remove compiler warnings in ent
try to fix io_waituntil2 on freebsd
This commit is contained in:
parent
dc69bc24ec
commit
bbaf63c7fd
12
ent.c
12
ent.c
@ -5,6 +5,7 @@
|
|||||||
#include "scan.h"
|
#include "scan.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
|
#define INTERNAL
|
||||||
#include "scan/scan_ulong.c"
|
#include "scan/scan_ulong.c"
|
||||||
#include "scan/scan_ulongn.c"
|
#include "scan/scan_ulongn.c"
|
||||||
#include "fmt/fmt_utf8.c"
|
#include "fmt/fmt_utf8.c"
|
||||||
@ -23,7 +24,7 @@ struct entity {
|
|||||||
}* root,** cur=&root;
|
}* root,** cur=&root;
|
||||||
|
|
||||||
struct letter {
|
struct letter {
|
||||||
char c;
|
unsigned char c;
|
||||||
struct letters* weiter;
|
struct letters* weiter;
|
||||||
uint32_t marshaled; // lower 8 bits: char. rest: ofs from start of marshaled blob
|
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) {
|
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);
|
heap=malloc((nodes+1)*sizeof(uint32_t)+datasize);
|
||||||
if (!heap) nomem();
|
if (!heap) nomem();
|
||||||
marshaled=(uint32_t*)heap;
|
marshaled=(uint32_t*)heap;
|
||||||
marshaled[0]=nodes+1;
|
marshaled[0]=nodes+1;
|
||||||
data=heap+(nodes+1)*sizeof(uint32_t);
|
data=heap+(nodes+1)*sizeof(uint32_t);
|
||||||
marshalhelper(s);
|
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) {
|
char* lookup(char* ds,size_t ofs,const char* t) {
|
||||||
@ -168,7 +169,8 @@ int main() {
|
|||||||
if (!(*s=='"')) continue;
|
if (!(*s=='"')) continue;
|
||||||
++s;
|
++s;
|
||||||
entity=s;
|
entity=s;
|
||||||
if (*entity!='&') continue; ++entity; ++s;
|
if (*entity!='&') continue;
|
||||||
|
++entity; ++s;
|
||||||
for (; *s && *s!='"'; ++s) ; // skip to end of entity
|
for (; *s && *s!='"'; ++s) ; // skip to end of entity
|
||||||
if (!(*s=='"')) continue;
|
if (!(*s=='"')) continue;
|
||||||
if (s[-1]!=';') continue;
|
if (s[-1]!=';') continue;
|
||||||
@ -216,7 +218,7 @@ int main() {
|
|||||||
{
|
{
|
||||||
FILE* f=fopen("entities.h","w");
|
FILE* f=fopen("entities.h","w");
|
||||||
size_t i;
|
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<marshaled[0]; ++i) {
|
for (i=0; i<marshaled[0]; ++i) {
|
||||||
if (i%8 == 0) fprintf(f,"\n ");
|
if (i%8 == 0) fprintf(f,"\n ");
|
||||||
fprintf(f,"0x%x,",marshaled[i]);
|
fprintf(f,"0x%x,",marshaled[i]);
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <assert.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef EPOLLRDNORM
|
#ifndef EPOLLRDNORM
|
||||||
@ -132,7 +133,13 @@ int64 io_waituntil2(int64 milliseconds) {
|
|||||||
first_deferred=-1; // can't happen
|
first_deferred=-1; // can't happen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* if no interest in events has been registered, then return
|
||||||
|
* immediately */
|
||||||
if (!io_wanted_fds) return 0;
|
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
|
#ifdef HAVE_EPOLL
|
||||||
if (io_waitmode==EPOLL) {
|
if (io_waitmode==EPOLL) {
|
||||||
int n;
|
int n;
|
||||||
@ -261,11 +268,17 @@ int64 io_waituntil2(int64 milliseconds) {
|
|||||||
}
|
}
|
||||||
if (!e->canread && (y[n].filter==EVFILT_READ)) {
|
if (!e->canread && (y[n].filter==EVFILT_READ)) {
|
||||||
e->canread=1;
|
e->canread=1;
|
||||||
|
#ifdef DEBUG
|
||||||
|
assert(e->next_read==-1);
|
||||||
|
#endif
|
||||||
e->next_read=first_readable;
|
e->next_read=first_readable;
|
||||||
first_readable=y[n].ident;
|
first_readable=y[n].ident;
|
||||||
}
|
}
|
||||||
if (!e->canwrite && (y[n].filter==EVFILT_WRITE)) {
|
if ((y[n].filter==EVFILT_WRITE)) {
|
||||||
e->canwrite=1;
|
e->canwrite=1;
|
||||||
|
#ifdef DEBUG
|
||||||
|
assert(e->next_write==-1);
|
||||||
|
#endif
|
||||||
e->next_write=first_writeable;
|
e->next_write=first_writeable;
|
||||||
first_writeable=y[i].ident;
|
first_writeable=y[i].ident;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#include "scan.h"
|
#include "scan.h"
|
||||||
|
#ifndef INTERNAL
|
||||||
#include "haveuint128.h"
|
#include "haveuint128.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
size_t scan_ulongn(const char* src,size_t n,unsigned long int* dest) {
|
size_t scan_ulongn(const char* src,size_t n,unsigned long int* dest) {
|
||||||
register const char *tmp=src;
|
register const char *tmp=src;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user