From: Wouter Wijngaards Date: Thu, 16 Jan 2014 16:01:37 +0000 (+0000) Subject: - Windows port, adjust %lld to %I64d, and warning in win_event.c. X-Git-Tag: release-1.4.22rc1~52 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3ce7b4a6fa1171fc16ae5f62cf29c8687b88ec6a;p=thirdparty%2Funbound.git - Windows port, adjust %lld to %I64d, and warning in win_event.c. git-svn-id: file:///svn/unbound/trunk@3040 be551aaa-1e26-0410-a405-d3ace91eadb9 --- diff --git a/config.h.in b/config.h.in index 17cf28bdf..0b56f4f0e 100644 --- a/config.h.in +++ b/config.h.in @@ -744,6 +744,12 @@ #include #endif +#ifndef USE_WINSOCK +#define ARG_LL "%ll" +#else +#define ARG_LL "%I64" +#endif + #ifdef HAVE_ATTR_FORMAT diff --git a/configure.ac b/configure.ac index efc1a4a5d..0fba9344f 100644 --- a/configure.ac +++ b/configure.ac @@ -1111,6 +1111,12 @@ dnl includes #ifdef HAVE_WS2TCPIP_H #include #endif + +#ifndef USE_WINSOCK +#define ARG_LL "%ll" +#else +#define ARG_LL "%I64" +#endif ] AHX_CONFIG_FORMAT_ATTRIBUTE diff --git a/daemon/cachedump.c b/daemon/cachedump.c index 8c8fec542..955689cdb 100644 --- a/daemon/cachedump.c +++ b/daemon/cachedump.c @@ -82,7 +82,7 @@ dump_rrset(SSL* ssl, struct ub_packed_rrset_key* k, if(d->ttl < now) return 1; /* expired */ /* meta line */ - if(!ssl_printf(ssl, ";rrset%s %lld %u %u %d %d\n", + if(!ssl_printf(ssl, ";rrset%s " ARG_LL "d %u %u %d %d\n", (k->rk.flags & PACKED_RRSET_NSEC_AT_APEX)?" nsec_apex":"", (long long)(d->ttl - now), (unsigned)d->count, (unsigned)d->rrsig_count, @@ -189,7 +189,7 @@ dump_msg(SSL* ssl, struct query_info* k, struct reply_info* d, } /* meta line */ - if(!ssl_printf(ssl, "msg %s %s %s %d %d %lld %d %u %u %u\n", + if(!ssl_printf(ssl, "msg %s %s %s %d %d " ARG_LL "d %d %u %u %u\n", nm, cl, tp, (int)d->flags, (int)d->qdcount, (long long)(d->ttl-now), (int)d->security, @@ -461,7 +461,7 @@ load_rrset(SSL* ssl, sldns_buffer* buf, struct worker* worker) s += 10; rk->rk.flags |= PACKED_RRSET_NSEC_AT_APEX; } - if(sscanf(s, " %lld %u %u %u %u", &ttl, &rr_count, &rrsig_count, + if(sscanf(s, " " ARG_LL "d %u %u %u %u", &ttl, &rr_count, &rrsig_count, &trust, &security) != 5) { log_warn("error bad rrset spec %s", s); return 0; @@ -636,7 +636,7 @@ load_msg(SSL* ssl, sldns_buffer* buf, struct worker* worker) } /* read remainder of line */ - if(sscanf(s, " %u %u %lld %u %u %u %u", &flags, &qdcount, &ttl, + if(sscanf(s, " %u %u " ARG_LL "d %u %u %u %u", &flags, &qdcount, &ttl, &security, &an, &ns, &ar) != 7) { log_warn("error cannot parse numbers: %s", s); return 0; @@ -742,8 +742,8 @@ print_dp_details(SSL* ssl, struct worker* worker, struct delegpt* dp) return; continue; /* skip stuff not in infra cache */ } - if(!ssl_printf(ssl, "%s%s%s%srto %d msec, ttl %lld, ping %d " - "var %d rtt %d, tA %d, tAAAA %d, tother %d", + if(!ssl_printf(ssl, "%s%s%s%srto %d msec, ttl " ARG_LL "d, " + "ping %d var %d rtt %d, tA %d, tAAAA %d, tother %d", lame?"LAME ":"", dlame?"NoDNSSEC ":"", a->lame?"AddrWasParentSide ":"", rlame?"NoAuthButRecursive ":"", rto, entry_ttl, diff --git a/daemon/remote.c b/daemon/remote.c index ffb0a24e5..9f93e6043 100644 --- a/daemon/remote.c +++ b/daemon/remote.c @@ -632,7 +632,7 @@ print_stats(SSL* ssl, const char* nm, struct stats_info* s) if(!ssl_printf(ssl, "%s.requestlist.current.user"SQ"%u\n", nm, (unsigned)s->mesh_num_reply_states)) return 0; timeval_divide(&avg, &s->mesh_replies_sum_wait, s->mesh_replies_sent); - if(!ssl_printf(ssl, "%s.recursion.time.avg"SQ"%lld.%6.6d\n", nm, + if(!ssl_printf(ssl, "%s.recursion.time.avg"SQ ARG_LL "d.%6.6d\n", nm, (long long)avg.tv_sec, (int)avg.tv_usec)) return 0; if(!ssl_printf(ssl, "%s.recursion.time.median"SQ"%g\n", nm, s->mesh_time_median)) return 0; @@ -716,11 +716,11 @@ print_uptime(SSL* ssl, struct worker* worker, int reset) timeval_subtract(&dt, &now, &worker->daemon->time_last_stat); if(reset) worker->daemon->time_last_stat = now; - if(!ssl_printf(ssl, "time.now"SQ"%lld.%6.6d\n", + if(!ssl_printf(ssl, "time.now"SQ ARG_LL "d.%6.6d\n", (long long)now.tv_sec, (unsigned)now.tv_usec)) return 0; - if(!ssl_printf(ssl, "time.up"SQ"%lld.%6.6d\n", + if(!ssl_printf(ssl, "time.up"SQ ARG_LL "d.%6.6d\n", (long long)up.tv_sec, (unsigned)up.tv_usec)) return 0; - if(!ssl_printf(ssl, "time.elapsed"SQ"%lld.%6.6d\n", + if(!ssl_printf(ssl, "time.elapsed"SQ ARG_LL "d.%6.6d\n", (long long)dt.tv_sec, (unsigned)dt.tv_usec)) return 0; return 1; } @@ -1728,7 +1728,7 @@ do_status(SSL* ssl, struct worker* worker) if(!ssl_printf(ssl, " ]\n")) return; uptime = (time_t)time(NULL) - (time_t)worker->daemon->time_boot.tv_sec; - if(!ssl_printf(ssl, "uptime: %lld seconds\n", (long long)uptime)) + if(!ssl_printf(ssl, "uptime: " ARG_LL "d seconds\n", (long long)uptime)) return; if(!ssl_printf(ssl, "unbound (pid %d) is running...\n", (int)getpid())) @@ -1747,7 +1747,8 @@ get_mesh_age(struct mesh_state* m, char* buf, size_t len, while(r && r->next) r = r->next; timeval_subtract(&d, env->now_tv, &r->start_time); - snprintf(buf, len, "%lld.%6.6d", (long long)d.tv_sec, (int)d.tv_usec); + snprintf(buf, len, ARG_LL "d.%6.6d", + (long long)d.tv_sec, (int)d.tv_usec); } else { snprintf(buf, len, "-"); } diff --git a/doc/Changelog b/doc/Changelog index de6ca0c27..beb7451ad 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -1,6 +1,7 @@ 16 January 2014: Wouter - fix #544: Fixed +i causes segfault when running with module conf "iterator". + - Windows port, adjust %lld to %I64d, and warning in win_event.c. 14 January 2014: Wouter - iana portlist updated. diff --git a/ldns/wire2str.c b/ldns/wire2str.c index a61c17648..21cf5a63d 100644 --- a/ldns/wire2str.c +++ b/ldns/wire2str.c @@ -1019,7 +1019,11 @@ int sldns_wire2str_tsigtime_scan(uint8_t** d, size_t* dl, char** s, size_t* sl) d4 = (*d)[4]; d5 = (*d)[5]; tsigtime = (d0<<40) | (d1<<32) | (d2<<24) | (d3<<16) | (d4<<8) | d5; +#ifndef USE_WINSOCK w = sldns_str_print(s, sl, "%llu", (long long)tsigtime); +#else + w = sldns_str_print(s, sl, "%I64u", (long long)tsigtime); +#endif (*d)+=6; (*dl)-=6; return w; @@ -1647,8 +1651,13 @@ int sldns_wire2str_edns_llq_print(char** s, size_t* sl, uint8_t* data, if(error_code < llq_errors_num) w += sldns_str_print(s, sl, " %s", llq_errors[error_code]); else w += sldns_str_print(s, sl, " error %d", (int)error_code); +#ifndef USE_WINSOCK w += sldns_str_print(s, sl, " id %llx lease-life %lu", (unsigned long long)llq_id, (unsigned long)lease_life); +#else + w += sldns_str_print(s, sl, " id %I64x lease-life %lu", + (unsigned long long)llq_id, (unsigned long)lease_life); +#endif return w; } diff --git a/services/mesh.c b/services/mesh.c index c40efdb23..e362ed833 100644 --- a/services/mesh.c +++ b/services/mesh.c @@ -892,7 +892,7 @@ mesh_send_reply(struct mesh_state* m, int rcode, struct reply_info* rep, m->s.env->mesh->num_reply_addrs--; end_time = *m->s.env->now_tv; timeval_subtract(&duration, &end_time, &r->start_time); - verbose(VERB_ALGO, "query took %lld.%6.6d sec", + verbose(VERB_ALGO, "query took " ARG_LL "d.%6.6d sec", (long long)duration.tv_sec, (int)duration.tv_usec); m->s.env->mesh->replies_sent++; timeval_add(&m->s.env->mesh->replies_sum_wait, &duration); @@ -1138,7 +1138,8 @@ mesh_stats(struct mesh_area* mesh, const char* str) timeval_divide(&avg, &mesh->replies_sum_wait, mesh->replies_sent); log_info("average recursion processing time " - "%lld.%6.6d sec", (long long)avg.tv_sec, (int)avg.tv_usec); + ARG_LL "d.%6.6d sec", + (long long)avg.tv_sec, (int)avg.tv_usec); log_info("histogram of recursion processing times"); timehist_log(mesh->histogram, "recursions"); } diff --git a/testcode/memstats.c b/testcode/memstats.c index 8cbd9f546..79347b4c5 100644 --- a/testcode/memstats.c +++ b/testcode/memstats.c @@ -189,7 +189,7 @@ readfile(rbtree_t* tree, const char* fname) char buf[102400]; if(!in) fatal_exit("could not open %s: %s", fname, strerror(errno)); - printf("Reading %s of size %lld\n", fname, (long long)total); + printf("Reading %s of size " ARG_LL "d\n", fname, (long long)total); while(fgets(buf, 102400, in)) { buf[102400-1] = 0; done += (off_t)strlen(buf); diff --git a/testcode/replay.c b/testcode/replay.c index 41c01c69f..e01851b12 100644 --- a/testcode/replay.c +++ b/testcode/replay.c @@ -792,7 +792,7 @@ macro_expand(rbtree_t* store, struct replay_runtime* runtime, char** text) /* check for functions */ if(strcmp(buf, "time") == 0) { - snprintf(buf, sizeof(buf), "%lld", (long long)runtime->now_secs); + snprintf(buf, sizeof(buf), ARG_LL "d", (long long)runtime->now_secs); *text += len; return strdup(buf); } else if(strcmp(buf, "timeout") == 0) { @@ -800,7 +800,7 @@ macro_expand(rbtree_t* store, struct replay_runtime* runtime, char** text) struct fake_timer* t = first_timer(runtime); if(t && (time_t)t->tv.tv_sec >= runtime->now_secs) res = (time_t)t->tv.tv_sec - runtime->now_secs; - snprintf(buf, sizeof(buf), "%lld", (long long)res); + snprintf(buf, sizeof(buf), ARG_LL "d", (long long)res); *text += len; return strdup(buf); } else if(strncmp(buf, "ctime ", 6) == 0 || diff --git a/util/log.c b/util/log.c index f4b63cbad..c1bcee0c7 100644 --- a/util/log.c +++ b/util/log.c @@ -230,7 +230,7 @@ log_vmsg(int pri, const char* type, ident, (int)getpid(), tid?*tid:0, type, message); } else #endif - fprintf(logfile, "[%lld] %s[%d:%x] %s: %s\n", (long long)now, + fprintf(logfile, "[" ARG_LL "d] %s[%d:%x] %s: %s\n", (long long)now, ident, (int)getpid(), tid?*tid:0, type, message); #ifdef UB_ON_WINDOWS /* line buffering does not work on windows */ diff --git a/util/winsock_event.c b/util/winsock_event.c index 681a91b24..6cc315a84 100644 --- a/util/winsock_event.c +++ b/util/winsock_event.c @@ -41,6 +41,9 @@ #include "config.h" #ifdef USE_WINSOCK #include +#ifdef HAVE_TIME_H +#include +#endif #ifdef HAVE_SYS_TIME_H #include #endif @@ -184,7 +187,7 @@ static void handle_timeouts(struct event_base* base, struct timeval* now, wait->tv_usec = p->ev_timeout.tv_usec - now->tv_usec; } - verbose(VERB_CLIENT, "winsock_event wait=%lld.%6.6d", + verbose(VERB_CLIENT, "winsock_event wait=" ARG_LL "d.%6.6d", (long long)wait->tv_sec, (int)wait->tv_usec); return; } @@ -491,7 +494,7 @@ int event_base_set(struct event_base *base, struct event *ev) int event_add(struct event *ev, struct timeval *tv) { - verbose(VERB_ALGO, "event_add %p added=%d fd=%d tv=%lld %s%s%s", + verbose(VERB_ALGO, "event_add %p added=%d fd=%d tv=" ARG_LL "d %s%s%s", ev, ev->added, ev->ev_fd, (tv?(long long)tv->tv_sec*1000+(long long)tv->tv_usec/1000:-1), (ev->ev_events&EV_READ)?" EV_READ":"", @@ -572,7 +575,7 @@ int event_add(struct event *ev, struct timeval *tv) int event_del(struct event *ev) { - verbose(VERB_ALGO, "event_del %p added=%d fd=%d tv=%lld %s%s%s", + verbose(VERB_ALGO, "event_del %p added=%d fd=%d tv=" ARG_LL "d %s%s%s", ev, ev->added, ev->ev_fd, (ev->ev_events&EV_TIMEOUT)?(long long)ev->ev_timeout.tv_sec*1000+ (long long)ev->ev_timeout.tv_usec/1000:-1, diff --git a/validator/autotrust.c b/validator/autotrust.c index c31415429..c848d427f 100644 --- a/validator/autotrust.c +++ b/validator/autotrust.c @@ -1643,7 +1643,7 @@ check_holddown(struct module_env* env, struct autr_ta* ta, if (elapsed > (time_t)holddown) { return elapsed-(time_t)holddown; } - verbose_key(ta, VERB_ALGO, "holddown time %lld seconds to go", + verbose_key(ta, VERB_ALGO, "holddown time " ARG_LL "d seconds to go", (long long) ((time_t)holddown-elapsed)); return 0; } @@ -1687,7 +1687,7 @@ do_addtime(struct module_env* env, struct autr_ta* anchor, int* c) time_t exceeded = check_holddown(env, anchor, env->cfg->add_holddown); if (exceeded && anchor->s == AUTR_STATE_ADDPEND) { verbose_key(anchor, VERB_ALGO, "add-holddown time exceeded " - "%lld seconds ago, and pending-count %d", + ARG_LL "d seconds ago, and pending-count %d", (long long)exceeded, anchor->pending_count); if(anchor->pending_count >= MIN_PENDINGCOUNT) { set_trustanchor_state(env, anchor, c, AUTR_STATE_VALID); @@ -1706,7 +1706,7 @@ do_remtime(struct module_env* env, struct autr_ta* anchor, int* c) time_t exceeded = check_holddown(env, anchor, env->cfg->del_holddown); if(exceeded && anchor->s == AUTR_STATE_REVOKED) { verbose_key(anchor, VERB_ALGO, "del-holddown time exceeded " - "%lld seconds ago", (long long)exceeded); + ARG_LL "d seconds ago", (long long)exceeded); set_trustanchor_state(env, anchor, c, AUTR_STATE_REMOVED); } } @@ -1884,7 +1884,7 @@ remove_missing_trustanchors(struct module_env* env, struct trust_anchor* tp, * one valid KSK: remove missing trust anchor */ if (exceeded && valid > 0) { verbose_key(anchor, VERB_ALGO, "keep-missing time " - "exceeded %lld seconds ago, [%d key(s) VALID]", + "exceeded " ARG_LL "d seconds ago, [%d key(s) VALID]", (long long)exceeded, valid); set_trustanchor_state(env, anchor, changed, AUTR_STATE_REMOVED); @@ -1988,7 +1988,7 @@ reset_worker_timer(struct module_env* env) #endif tv.tv_usec = 0; comm_timer_set(env->probe_timer, &tv); - verbose(VERB_ALGO, "scheduled next probe in %lld sec", (long long)tv.tv_sec); + verbose(VERB_ALGO, "scheduled next probe in " ARG_LL "d sec", (long long)tv.tv_sec); } /** set next probe for trust anchor */