Commit b5d0bc5e authored by Pekka Pessi's avatar Pekka Pessi

Using autoconf to figure out 64-bit types. Avoid off_t and 64-bit constants.

darcs-hash:20050908152635-65a35-f0bb1705406948290003acb83f099c0be9167bda.gz
parent 327c1a11
......@@ -66,6 +66,12 @@ dnl XXX
### ----------------
AC_TYPE_SIGNAL
AC_CHECK_TYPE([long long],[
AC_DEFINE([longlong], [long long], [Define as at least 64-bit int type])dnl
AC_DEFINE([LLU], ["%llu"], [Define as format (%llu) for unsigned long long])dnl
AC_DEFINE([LLI], ["%lli"], [Define as format (%lli) for long long])dnl
AC_DEFINE([LLX], ["%llx"], [Define as format (%llx) for long long hex])dnl
])dnl
dnl checks for structures
dnl ---------------------
......
......@@ -79,7 +79,7 @@ sip_payload_t *sl_fread_payload(su_home_t *home, FILE *f)
int n;
char *buf;
char const *who;
off_t used, size;
size_t used, size;
if (f == NULL) {
errno = EINVAL;
......
......@@ -114,8 +114,7 @@ const char _nua_stack_c_id[] =
#include "nua_stack.h"
typedef long long unsigned LLU;
typedef unsigned longlong ull;
/* ========================================================================
*
......@@ -2952,9 +2951,9 @@ char const *nh_recv_offer_answer(nua_handle_t *nh,
*return_new_version = 0;
}
SU_DEBUG_5(("nua: %s: %s (o=%s %llu %llu)\n",
SU_DEBUG_5(("nua: %s: %s (o=%s "LLU" "LLU")\n",
"nh_recv_offer_answer", verdict ? verdict : "ignored",
o->o_username, (LLU)o->o_id, (LLU)o->o_version));
o->o_username, (ull)o->o_id, (ull)o->o_version));
return verdict;
}
......@@ -2992,9 +2991,9 @@ char const *nh_sent_offer_answer(nua_handle_t *nh,
ss->ss_o_local = sdp_origin_dup(nh->nh_home, o);
}
SU_DEBUG_5(("nua: %s: %s (o=%s %llu %llu)\n",
SU_DEBUG_5(("nua: %s: %s (o=%s "LLU" "LLU")\n",
"nh_sent_offer_answer", verdict ? verdict : "ignored",
o->o_username, (LLU)o->o_id, (LLU)o->o_version));
o->o_username, (ull)o->o_id, (ull)o->o_version));
return verdict;
}
......
......@@ -1664,12 +1664,12 @@ static int parse_ul(sdp_parser_t *p, char **r,
}
/*
* parse_ul: parse an unsigned long
* parse_ull: parse an unsigned long long
*/
static int parse_ull(sdp_parser_t *p, char **r,
uint64_t *result, uint64_t max)
{
unsigned long long ull;
unsigned longlong ull;
char *s = *r;
......@@ -1686,7 +1686,6 @@ static int parse_ull(sdp_parser_t *p, char **r,
return -1;
}
static char *token(char **message,
const char *sep,
const char *legal,
......
......@@ -50,12 +50,12 @@ const char _sdp_print_c_id[] =
/* Printing API */
/* */
typedef long long unsigned LLU;
#define SDP_BLOCK (512)
#define CRLF "\015\012"
typedef unsigned long long ull;
struct sdp_printer_s {
int pr_size;
su_home_t *pr_home;
......@@ -306,10 +306,10 @@ static void print_origin(sdp_printer_t *p, sdp_origin_t const *o)
return;
}
sdp_printf(p, "o=%s %llu %llu ",
sdp_printf(p, "o=%s "LLU" "LLU" ",
o->o_username,
(LLU)o->o_id,
(LLU)o->o_version);
(ull)o->o_id,
(ull)o->o_version);
print_connection2(p, o->o_address);
}
......
......@@ -446,21 +446,21 @@ int validate_dump(char *b, off_t size, context_t *ctx)
return 0;
}
typedef long long unsigned llu;
typedef unsigned longlong ull;
static
void report_memstats(char const *title, su_home_stat_t const hs[1])
{
printf("%s%smemory statistics\n", title, strlen(title) ? " " : "");
if (hs->hs_allocs.hsa_number)
printf("\t%llu allocs, %llu bytes, %llu rounded,"
" %llu max\n",
(llu)hs->hs_allocs.hsa_number, (llu)hs->hs_allocs.hsa_bytes,
(llu)hs->hs_allocs.hsa_rbytes, (llu)hs->hs_allocs.hsa_maxrbytes);
printf("\t"LLU" allocs, "LLU" bytes, "LLU" rounded,"
" "LLU" max\n",
(ull)hs->hs_allocs.hsa_number, (ull)hs->hs_allocs.hsa_bytes,
(ull)hs->hs_allocs.hsa_rbytes, (ull)hs->hs_allocs.hsa_maxrbytes);
if (hs->hs_frees.hsf_number)
printf("\t%llu frees, %llu bytes, rounded to %llu bytes\n",
(llu)hs->hs_frees.hsf_number, (llu)hs->hs_frees.hsf_bytes,
(llu)hs->hs_frees.hsf_rbytes);
printf("\t"LLU" frees, "LLU" bytes, rounded to "LLU" bytes\n",
(ull)hs->hs_frees.hsf_number, (ull)hs->hs_frees.hsf_bytes,
(ull)hs->hs_frees.hsf_rbytes);
if (hs->hs_rehash || hs->hs_clones)
printf("\t%d rehashes, %d clones\n", hs->hs_rehash, hs->hs_clones);
}
......@@ -498,13 +498,13 @@ void memstats(msg_t *msg, uint32_t msize, context_t *ctx)
void report_sipstat(char const *what, sipstat_t const *sss)
{
printf("%s: %llu with %.1f headers (total %llu)\n",
what, (llu)sss->number, (double)sss->headers / sss->number,
(llu)sss->headers);
printf("%s: "LLU" with %.1f headers (total "LLU")\n",
what, (ull)sss->number, (double)sss->headers / sss->number,
(ull)sss->headers);
if (sss->payloads)
printf("\t%llu with body of %.1f bytes (total %llu)\n",
(llu)sss->payloads, (double)sss->pl_bytes / sss->payloads,
(llu)sss->payloads);
printf("\t"LLU" with body of %.1f bytes (total "LLU")\n",
(ull)sss->payloads, (double)sss->pl_bytes / sss->payloads,
(ull)sss->payloads);
}
void sipstats(msg_t *msg, uint32_t msize, sipstats_t *ss, context_t *ctx)
......@@ -587,15 +587,15 @@ int report(context_t const *ctx)
if (!n)
return -1;
printf("total %llu messages with %llu bytes (mean size %llu)\n",
(llu)n, (llu)ctx->bytes, (llu)(ctx->bytes / n));
printf("total "LLU" messages with "LLU" bytes (mean size "LLU")\n",
(ull)n, (ull)ctx->bytes, (ull)(ctx->bytes / n));
if (ctx->hist_msgsize)
report_histogram("Message size", ctx->hist_msgsize);
if (o->o_times && ctx->files > 1)
printf("total %llu messages in %g seconds (%g msg/sec)\n",
(llu)n, ctx->time, (double)n / ctx->time);
printf("total "LLU" messages in %g seconds (%g msg/sec)\n",
(ull)n, ctx->time, (double)n / ctx->time);
if (o->o_sipstats) {
sipstats_t *ss = ctx->sipstats;
......
......@@ -58,7 +58,8 @@ const char soa_add_h_id[] = SOA_ADD_H;
#define NONE ((void *)-1)
#define XXX assert(!"implemented")
typedef long long unsigned llu;
typedef unsigned longlong ull;
/* ======================================================================== */
......@@ -1119,9 +1120,9 @@ int soa_remote_sdp(soa_session_t *ss, sdp_parser_t *parser,
ss->ss_answer_sent = 0;
}
SU_DEBUG_5(("%s(%p): %s%s (o=%s %llu %llu)\n",
SU_DEBUG_5(("%s(%p): %s%s (o=%s "LLU" "LLU")\n",
"soa_parse_sdp", ss, new_version ? "new " : "", verdict,
o->o_username, (llu)o->o_id, (llu)o->o_version));
o->o_username, (ull)o->o_id, (ull)o->o_version));
return new_version;
}
......
......@@ -253,7 +253,7 @@ uint32_t su_ntp_hi(su_ntp_t ntp)
su_ntp_t su_ntp_hilo(uint32_t hi, uint32_t lo)
{
return (((su_ntp_t)hi << 32) & 0xffffffff00000000LLU) | lo;
return ((((su_ntp_t)hi) << 32)) | lo;
}
/** Low 32 bit of NTP timestamp.
......
......@@ -165,7 +165,7 @@ enum {
#define END(flags) } END_(flags)
#endif
#define LLU long long unsigned
typedef unsigned long long ull;
/** @HIDE */
#define TEST_1_(flags, suite) do { \
......@@ -209,9 +209,9 @@ enum {
if ((_value = (uint64_t)(suite)) == (_expect = (uint64_t)(expect))) \
{ if (flags & tst_verbatim) \
printf("%s: %s%sok: %s == %s \n", TSTNAME, #suite, #expect); break; } \
fprintf(stderr, "%s:%u: %s %s%sFAILED: %s != %s or %llu != %llu\n", \
fprintf(stderr, "%s:%u: %s %s%sFAILED: %s != %s or "LLU" != "LLU"\n", \
__FILE__, __LINE__, TSTNAME, \
#suite, #expect, (LLU)_value, (LLU)_expect); fflush(stderr); \
#suite, #expect, (ull)_value, (ull)_expect); fflush(stderr); \
return 1; \
} while(0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment