Skip to content

Commit

Permalink
i#58 MacOS: fix several minor build issues:
Browse files Browse the repository at this point in the history
1) Fix build warning on MacOS in LINKSTUB_NEXT_INCOMING due to type
   mismatch

2) Avoid built-in tolower in favor of our own

3) timeval.tv_usec is int, not long, in runstats tool

SVN-Revision: 2317
  • Loading branch information
derekbruening committed Oct 8, 2013
1 parent a43cb32 commit 5367622
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
11 changes: 6 additions & 5 deletions core/io.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* **********************************************************
* Copyright (c) 2011-2012 Google, Inc. All rights reserved.
* Copyright (c) 2011-2013 Google, Inc. All rights reserved.
* Copyright (c) 2002-2010 VMware, Inc. All rights reserved.
* **********************************************************/

Expand Down Expand Up @@ -45,11 +45,12 @@
#include <stdarg.h> /* for varargs */

#ifdef UNIX
# ifdef MACOS
# ifdef MACOS
/* request extern functions to avoid conflicts with our own tolower() */
# define _EXTERNALIZE_CTYPE_INLINES_TOP_
# endif
# include <wchar.h>
# define _EXTERNALIZE_CTYPE_INLINES_TOP_
# define _EXTERNALIZE_CTYPE_INLINES_
# endif
# include <wchar.h>
#endif

#ifdef NOT_DYNAMORIO_CORE_PROPER
Expand Down
6 changes: 3 additions & 3 deletions core/link.h
Original file line number Diff line number Diff line change
Expand Up @@ -331,10 +331,10 @@ typedef struct _coarse_incoming_t {
*/
#define LINKSTUB_NEXT_INCOMING(l) \
(LINKSTUB_NORMAL_DIRECT((l)->flags) ? \
(((direct_linkstub_t *)(l))->cdl.next_incoming) : \
((linkstub_t*)(((direct_linkstub_t *)(l))->cdl.next_incoming)) : \
(LINKSTUB_CBR_FALLTHROUGH((l)->flags) ? \
(((cbr_fallthrough_linkstub_t *)(l))->cdl.next_incoming) : \
(ASSERT(false && "indirect linkstub has no next_incoming"), NULL)))
((linkstub_t*)(((cbr_fallthrough_linkstub_t *)(l))->cdl.next_incoming)) : \
(ASSERT(false && "indirect linkstub has no next_incoming"), ((linkstub_t*)NULL))))

/* if sharing a stub then no offs, else offs to get to subsequent stub */
#define CBR_FALLTHROUGH_STUB_OFFS(f) \
Expand Down
15 changes: 12 additions & 3 deletions tools/runstats.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@
* time limit expires
*/

#include "configure.h"

#ifdef MACOS
/* struct timeval.tv_usec is int, not long int */
# define USEC_FMT "d"
#else
# define USEC_FMT "ld"
#endif

#include <sys/types.h>
#include <unistd.h>
#include <sys/types.h> /* for wait and mmap */
Expand Down Expand Up @@ -265,7 +274,7 @@ print_stats(struct timeval *start, struct timeval *end,
(end->tv_sec % 3600) / 60,
end->tv_sec % 60);
} else {
fprintf(FP, "%ld:%02ld.%02ldelapsed ", /* -> m:s. */
fprintf(FP, "%ld:%02ld.%02"USEC_FMT"elapsed ", /* -> m:s. */
end->tv_sec / 60,
end->tv_sec % 60,
end->tv_usec / 10000);
Expand All @@ -275,9 +284,9 @@ print_stats(struct timeval *start, struct timeval *end,
fprintf(FP, "%lu%%CPU ", (v * 100 / r));
else
fprintf(FP, "?%%CPU ");
fprintf(FP, "%ld.%02lduser ",
fprintf(FP, "%ld.%02"USEC_FMT"user ",
ru->ru_utime.tv_sec, ru->ru_utime.TV_MSEC / 10);
fprintf(FP, "%ld.%02ldsystem ",
fprintf(FP, "%ld.%02"USEC_FMT"system ",
ru->ru_stime.tv_sec, ru->ru_stime.TV_MSEC / 10);
fprintf(FP, "(%ldmajor+%ldminor)pagefaults %ldswaps\n",
ru->ru_majflt,/* Major page faults. */
Expand Down

0 comments on commit 5367622

Please sign in to comment.