mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
build: various fixes for compiling on macOS
This commit is contained in:
@ -57,8 +57,6 @@
|
||||
#include "config.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <byteswap.h>
|
||||
#include <endian.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <limits.h>
|
||||
|
||||
@ -57,7 +57,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <assert.h>
|
||||
#include <endian.h>
|
||||
#ifdef __APPLE__
|
||||
# include <machine/endian.h>
|
||||
#else
|
||||
# include <endian.h>
|
||||
#endif
|
||||
#include <inttypes.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
@ -57,7 +57,11 @@
|
||||
#include "config.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <endian.h>
|
||||
#ifdef __APPLE__
|
||||
# include <machine/endian.h>
|
||||
#else
|
||||
# include <endian.h>
|
||||
#endif
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <limits.h>
|
||||
|
||||
@ -68,9 +68,13 @@ void
|
||||
sysprof_clock_init (void)
|
||||
{
|
||||
static const int clock_ids[] = {
|
||||
#ifdef __APPLE__
|
||||
_CLOCK_MONOTONIC,
|
||||
#else
|
||||
CLOCK_MONOTONIC,
|
||||
CLOCK_MONOTONIC_RAW,
|
||||
#endif
|
||||
#ifdef __linux__
|
||||
CLOCK_MONOTONIC_RAW,
|
||||
CLOCK_MONOTONIC_COARSE,
|
||||
CLOCK_REALTIME_COARSE,
|
||||
#endif
|
||||
|
||||
@ -80,7 +80,11 @@ sysprof_clock_get_current_time (void)
|
||||
SysprofClock clock = sysprof_clock;
|
||||
|
||||
if SYSPROF_UNLIKELY (clock == -1)
|
||||
#ifdef __APPLE__
|
||||
clock = _CLOCK_MONOTONIC;
|
||||
#else
|
||||
clock = CLOCK_MONOTONIC;
|
||||
#endif
|
||||
clock_gettime (clock, &ts);
|
||||
|
||||
return (ts.tv_sec * SYSPROF_NSEC_PER_SEC) + ts.tv_nsec;
|
||||
|
||||
@ -61,6 +61,14 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __APPLE__
|
||||
# include <libkern/OSByteOrder.h>
|
||||
# include <architecture/byte_order.h>
|
||||
#else
|
||||
# include <byteswap.h>
|
||||
# include <endian.h>
|
||||
#endif
|
||||
|
||||
#define sysprof_assert_not_reached() assert (false)
|
||||
|
||||
#define SYSPROF_N_ELEMENTS(a) (sizeof (a) / sizeof (*a))
|
||||
@ -77,3 +85,13 @@
|
||||
} while (0)
|
||||
|
||||
#define sysprof_strdup(s) ((s) ? strdup(s) : NULL)
|
||||
|
||||
#ifdef __APPLE__
|
||||
# define bswap_16 OSSwapInt16
|
||||
# define bswap_32 OSSwapInt32
|
||||
# define bswap_64 OSSwapInt64
|
||||
# define htole32 OSSwapHostToLittleInt32
|
||||
# define __BYTE_ORDER __DARWIN_BYTE_ORDER
|
||||
# define __LITTLE_ENDIAN __DARWIN_LITTLE_ENDIAN
|
||||
# define __BIG_ENDIAN __DARWIN_BIG_ENDIAN
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user