From: Wouter Wijngaards Date: Fri, 11 Jul 2014 11:49:27 +0000 (+0000) Subject: Fix for sun compiler. X-Git-Tag: release-1.5.0rc1~94 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3a9dee2e221c41c8a1bf075ccaca13d25c0b71a1;p=thirdparty%2Funbound.git Fix for sun compiler. git-svn-id: file:///svn/unbound/trunk@3166 be551aaa-1e26-0410-a405-d3ace91eadb9 --- diff --git a/compat/getentropy_solaris.c b/compat/getentropy_solaris.c index c49ea151e..abd387701 100644 --- a/compat/getentropy_solaris.c +++ b/compat/getentropy_solaris.c @@ -62,10 +62,15 @@ #define HR(x, l) (SHA512_Update(&ctx, (char *)(x), (l))) #define HD(x) (SHA512_Update(&ctx, (char *)&(x), sizeof (x))) +/* for functions. sun-cc cannot take sizeof a function pointer */ +#define HF(x) (SHA512_Update(&ctx, (char *)&(x), sizeof (void*))) int getentropy(void *buf, size_t len); -extern int main(int, char *argv[]); +/* a function in the main program, but main is only in executables, + referencing main does not work in sun-cc, but does work with gcc */ +/* extern int main(int, char *argv[]); */ +extern void log_info(const char* format, ...); static int gotdata(char *buf, size_t len); static int getentropy_urandom(void *buf, size_t len); static int getentropy_fallback(void *buf, size_t len); @@ -180,7 +185,7 @@ start: } for (i = 0; i < len; ) { size_t wanted = len - i; - ssize_t ret = read(fd, buf + i, wanted); + ssize_t ret = read(fd, (char*)buf + i, wanted); if (ret == -1) { if (errno == EAGAIN || errno == EINTR) @@ -281,9 +286,11 @@ getentropy_fallback(void *buf, size_t len) HX(sigprocmask(SIG_BLOCK, NULL, &sigset) == -1, sigset); - HD(main); /* an addr in program */ - HD(getentropy); /* an addr in this library */ - HD(printf); /* an addr in libc */ + /* replaced main with log_info */ + /*HF(main);*/ /* an addr in program */ + HF(log_info); /* an addr in program */ + HF(getentropy); /* an addr in this library */ + HF(printf); /* an addr in libc */ p = (char *)&p; HD(p); /* an addr on stack */ p = (char *)&errno; @@ -401,7 +408,7 @@ getentropy_fallback(void *buf, size_t len) HD(cnt); } SHA512_Final(results, &ctx); - memcpy(buf + i, results, min(sizeof(results), len - i)); + memcpy((char*)buf + i, results, min(sizeof(results), len - i)); i += min(sizeof(results), len - i); } memset(results, 0, sizeof results);