mirror of
https://github.com/DynamoRIO/dynamorio.git
synced 2026-10-12 02:02:04 +00:00
i#8001 shared defs: Add project-wide header with ALIGN* macros (#8007)
Adds a new top-level header common/dr_project_wide_defines.h that is shared across all domains to avoid duplication. This PR moves just the ALIGN* macros into this header. More shared defines will be moved in further installments. The new header is installed into the drmemtrace export dir as A) we're already exporting utils.h which includes it and B) otherwise we have to duplicate some defines in trace_entry.h. However, I first tried duplicating and not including utils.h in trace_entry.h, which revealed several missing headers in clients/drcachesim/ files. I left those additions in this PR though they could be separated out. The new header includes stdint.h to avoid depending on DR API integer defines, which caused a Windows build issue which was resolved by removing defines we had added to libdwarf.h back when we supported VS2008 which did not have stdint.h. Those added defines are removed here. Issue: #8001
This commit is contained in:
@@ -1555,6 +1555,7 @@ endif (EXISTS ${defines_file})
|
||||
include_directories(BEFORE
|
||||
${PROJECT_BINARY_DIR} # for configure.h, configure_defines.h, events.h, and event_strings.h
|
||||
)
|
||||
include_directories(BEFORE ${PROJECT_SOURCE_DIR}/common)
|
||||
|
||||
# Export targets for importing by clients.
|
||||
# We include DynamoRIO and all Extensions in the same file for simplicity,
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#define CLIENTS_COMMON_UTILS_H_
|
||||
|
||||
#include "dr_api.h"
|
||||
#include "dr_project_wide_defines.h"
|
||||
|
||||
#ifdef DEBUG
|
||||
# define ASSERT(x, msg) DR_ASSERT_MSG(x, msg)
|
||||
@@ -48,7 +49,6 @@
|
||||
#define BUFFER_SIZE_ELEMENTS(buf) (BUFFER_SIZE_BYTES(buf) / sizeof((buf)[0]))
|
||||
#define BUFFER_LAST_ELEMENT(buf) (buf)[BUFFER_SIZE_ELEMENTS(buf) - 1]
|
||||
#define NULL_TERMINATE_BUFFER(buf) BUFFER_LAST_ELEMENT(buf) = 0
|
||||
#define ALIGNED(x, alignment) ((((ptr_uint_t)x) & ((alignment) - 1)) == 0)
|
||||
#define TESTANY(mask, var) (((mask) & (var)) != 0)
|
||||
#define TEST TESTANY
|
||||
|
||||
|
||||
@@ -380,6 +380,13 @@ if (liblz4)
|
||||
endif ()
|
||||
|
||||
link_with_pthread(drmemtrace_analyzer)
|
||||
# XXX i#8001: We'd prefer this header to be internal-only, but to avoid exposing
|
||||
# we'd have to duplicate some defines in trace_entry.h (TESTANY and
|
||||
# START_PACKED_STRUCTURE); even then, we expose utils.h, which includes it.
|
||||
# So we export it here. It's currently not exported in the DR API headers;
|
||||
# even if we add it there, it's ok to be in both.
|
||||
install_client_nonDR_header(.
|
||||
${PROJECT_SOURCE_DIR}/common/dr_project_wide_defines.h)
|
||||
# We get away w/ exporting the generically-named "utils.h" by putting into a
|
||||
# drmemtrace/ subdir.
|
||||
install_client_nonDR_header(drmemtrace common/utils.h)
|
||||
|
||||
@@ -47,12 +47,12 @@
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
#if defined(BUILD_PT_TRACER) || defined(BUILD_PT_POST_PROCESSOR)
|
||||
# include "drpttracer_shared.h"
|
||||
#endif
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
/**
|
||||
* @file drmemtrace/trace_entry.h
|
||||
* @brief DrMemtrace trace entry enum types and definitions.
|
||||
|
||||
@@ -52,10 +52,12 @@
|
||||
# include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#include "dr_project_wide_defines.h"
|
||||
|
||||
namespace dynamorio {
|
||||
namespace drmemtrace {
|
||||
|
||||
// XXX: DR should export this
|
||||
// TODO i#8001: Unify with DR's defines and move to dr_project_wide_defines.h.
|
||||
#define INVALID_THREAD_ID 0
|
||||
// We avoid collisions with DR's INVALID_PROCESS_ID by using our own name.
|
||||
#define INVALID_PID -1
|
||||
@@ -89,10 +91,6 @@ namespace drmemtrace {
|
||||
# define IF_REL_ADDRS(x)
|
||||
#endif
|
||||
|
||||
#define ALIGN_FORWARD(x, alignment) \
|
||||
((((ptr_uint_t)x) + ((alignment) - 1)) & (~((ptr_uint_t)(alignment) - 1)))
|
||||
#define ALIGN_BACKWARD(x, alignment) (((ptr_uint_t)x) & (~((ptr_uint_t)(alignment) - 1)))
|
||||
|
||||
#define NOTIFY(level, ...) \
|
||||
do { \
|
||||
if (op_verbose.get_value() >= (level)) \
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* **********************************************************
|
||||
* Copyright (c) 2018-2023 Google, LLC All rights reserved.
|
||||
* Copyright (c) 2018-2026 Google, LLC All rights reserved.
|
||||
* **********************************************************/
|
||||
|
||||
/*
|
||||
@@ -32,6 +32,7 @@
|
||||
|
||||
#include "config_reader.h"
|
||||
#include "config_reader_helpers.h"
|
||||
#include "utils.h"
|
||||
#include <sstream>
|
||||
#include <set>
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* **********************************************************
|
||||
* Copyright (c) 2022-2025 Google, Inc. All rights reserved.
|
||||
* Copyright (c) 2022-2026 Google, Inc. All rights reserved.
|
||||
* **********************************************************/
|
||||
|
||||
/*
|
||||
@@ -44,6 +44,7 @@
|
||||
#include "memtrace_stream.h"
|
||||
#include "reader_base.h"
|
||||
#include "trace_entry.h"
|
||||
#include "utils.h"
|
||||
|
||||
namespace dynamorio {
|
||||
namespace drmemtrace {
|
||||
|
||||
@@ -57,7 +57,6 @@ namespace drmemtrace {
|
||||
dr_abort(), 0) \
|
||||
: 0))
|
||||
#define ASSERT_NOT_REACHED() ASSERT_MSG(false, "Shouldn't be reached")
|
||||
#define ALIGNED(x, alignment) ((((ptr_uint_t)x) & ((alignment) - 1)) == 0)
|
||||
|
||||
/*******************************************************************************
|
||||
* Begin application code.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* **********************************************************
|
||||
* Copyright (c) 2020 Google, Inc. All rights reserved.
|
||||
* Copyright (c) 2020-2026 Google, Inc. All rights reserved.
|
||||
* **********************************************************/
|
||||
|
||||
/*
|
||||
@@ -32,6 +32,7 @@
|
||||
|
||||
#include "../common/trace_entry.h"
|
||||
#include "prefetch_analyzer.h"
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
|
||||
namespace dynamorio {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* **********************************************************
|
||||
* Copyright (c) 2015-2025 Google, LLC All rights reserved.
|
||||
* Copyright (c) 2015-2026 Google, LLC All rights reserved.
|
||||
* **********************************************************/
|
||||
|
||||
/*
|
||||
@@ -30,6 +30,7 @@
|
||||
* DAMAGE.
|
||||
*/
|
||||
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* **********************************************************
|
||||
* Copyright (c) 2021-2025 Google, LLC All rights reserved.
|
||||
* Copyright (c) 2021-2026 Google, LLC All rights reserved.
|
||||
* **********************************************************/
|
||||
|
||||
/*
|
||||
@@ -38,6 +38,7 @@
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
#include "memref.h"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* **********************************************************
|
||||
* Copyright (c) 2023-2025 Google, Inc. All rights reserved.
|
||||
* Copyright (c) 2023-2026 Google, Inc. All rights reserved.
|
||||
* **********************************************************/
|
||||
|
||||
/*
|
||||
@@ -41,6 +41,8 @@
|
||||
# error NDEBUG should not be set for tests.
|
||||
#endif
|
||||
|
||||
#include "dr_project_wide_defines.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
namespace dynamorio {
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include "dr_api.h"
|
||||
#include "tools/basic_counts.h"
|
||||
#include "memref_gen.h"
|
||||
#include "utils.h"
|
||||
|
||||
#include <cinttypes>
|
||||
#include <vector>
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
|
||||
#include "analysis_tool.h"
|
||||
#include "memref.h"
|
||||
#include "utils.h"
|
||||
|
||||
namespace dynamorio {
|
||||
namespace drmemtrace {
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
|
||||
#include "analysis_tool.h"
|
||||
#include "memref.h"
|
||||
#include "utils.h"
|
||||
|
||||
namespace dynamorio {
|
||||
namespace drmemtrace {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* **********************************************************
|
||||
* Copyright (c) 2015-2025 Google, Inc. All rights reserved.
|
||||
* Copyright (c) 2015-2026 Google, Inc. All rights reserved.
|
||||
* **********************************************************/
|
||||
|
||||
/*
|
||||
@@ -44,6 +44,7 @@
|
||||
#include "dr_api.h"
|
||||
#include "hashtable.h"
|
||||
#include "trace_entry.h"
|
||||
#include "utils.h"
|
||||
|
||||
namespace dynamorio {
|
||||
namespace drmemtrace {
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
/* **********************************************************
|
||||
* Copyright (c) 2010-2026 Google, Inc. All rights reserved.
|
||||
* Copyright (c) 2002-2010 VMware, Inc. All rights reserved.
|
||||
* **********************************************************/
|
||||
|
||||
/*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* * Neither the name of VMware, Inc. nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL VMWARE, INC. OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
* DAMAGE.
|
||||
*/
|
||||
|
||||
/* Copyright (c) 2003-2007 Determina Corp. */
|
||||
/* Copyright (c) 2002-2003 Massachusetts Institute of Technology */
|
||||
/* Copyright (c) 2002 Hewlett-Packard Company */
|
||||
|
||||
#ifndef _DR_PROJECT_WIDE_DEFINES_H_
|
||||
#define _DR_PROJECT_WIDE_DEFINES_H_
|
||||
|
||||
/* Defines shared across the core, tests, clients, and standalone applications.
|
||||
* Due to differing reporting and exiting environments, we cannot easily share
|
||||
* assert or logging defines, but we share other cross-domain utilities here.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/* Alignment helpers. The alignment must be a power of 2. */
|
||||
#define ALIGNED(x, alignment) ((((uintptr_t)x) & ((alignment) - 1)) == 0)
|
||||
#define ALIGN_FORWARD(x, alignment) \
|
||||
((((uintptr_t)x) + ((alignment) - 1)) & (~((uintptr_t)(alignment) - 1)))
|
||||
#define ALIGN_FORWARD_UINT(x, alignment) \
|
||||
((((unsigned int)x) + ((alignment) - 1)) & (~((alignment) - 1)))
|
||||
#define ALIGN_BACKWARD(x, alignment) (((uintptr_t)x) & (~((uintptr_t)(alignment) - 1)))
|
||||
#define PAD(length, alignment) (ALIGN_FORWARD((length), (alignment)) - (length))
|
||||
#define ALIGN_MOD(addr, size, alignment) \
|
||||
((((uintptr_t)addr) + (size) - 1) & ((alignment) - 1))
|
||||
#define CROSSES_ALIGNMENT(addr, size, alignment) \
|
||||
(ALIGN_MOD(addr, size, alignment) < (size) - 1)
|
||||
/* number of bytes you need to shift addr forward so that it's !CROSSES_ALIGNMENT */
|
||||
#define ALIGN_SHIFT_SIZE(addr, size, alignment) \
|
||||
(CROSSES_ALIGNMENT(addr, size, alignment) \
|
||||
? ((size) - 1 - ALIGN_MOD(addr, size, alignment)) \
|
||||
: 0)
|
||||
|
||||
#endif /* _DR_PROJECT_WIDE_DEFINES_H_ */
|
||||
+2
-18
@@ -42,6 +42,8 @@
|
||||
#ifndef _UTILS_H_
|
||||
#define _UTILS_H_
|
||||
|
||||
#include "dr_project_wide_defines.h"
|
||||
|
||||
#ifdef assert
|
||||
# undef assert
|
||||
#endif
|
||||
@@ -215,24 +217,6 @@ external_error(const char *file, int line, const char *msg);
|
||||
#define CLIENT_ASSERT_BITFIELD_TRUNCATE(width, val, msg) \
|
||||
CLIENT_ASSERT((val) < (1 << ((width) + 1)), msg);
|
||||
|
||||
/* alignment helpers, alignment must be power of 2 */
|
||||
#define ALIGNED(x, alignment) ((((ptr_uint_t)x) & ((alignment) - 1)) == 0)
|
||||
#define ALIGN_FORWARD(x, alignment) \
|
||||
((((ptr_uint_t)x) + ((alignment) - 1)) & (~((ptr_uint_t)(alignment) - 1)))
|
||||
#define ALIGN_FORWARD_UINT(x, alignment) \
|
||||
((((uint)x) + ((alignment) - 1)) & (~((alignment) - 1)))
|
||||
#define ALIGN_BACKWARD(x, alignment) (((ptr_uint_t)x) & (~((ptr_uint_t)(alignment) - 1)))
|
||||
#define PAD(length, alignment) (ALIGN_FORWARD((length), (alignment)) - (length))
|
||||
#define ALIGN_MOD(addr, size, alignment) \
|
||||
((((ptr_uint_t)addr) + (size) - 1) & ((alignment) - 1))
|
||||
#define CROSSES_ALIGNMENT(addr, size, alignment) \
|
||||
(ALIGN_MOD(addr, size, alignment) < (size) - 1)
|
||||
/* number of bytes you need to shift addr forward so that it's !CROSSES_ALIGNMENT */
|
||||
#define ALIGN_SHIFT_SIZE(addr, size, alignment) \
|
||||
(CROSSES_ALIGNMENT(addr, size, alignment) \
|
||||
? ((size) - 1 - ALIGN_MOD(addr, size, alignment)) \
|
||||
: 0)
|
||||
|
||||
/****************************************************************************
|
||||
* Synchronization
|
||||
*/
|
||||
|
||||
@@ -46,13 +46,13 @@
|
||||
|
||||
#include "configure.h"
|
||||
#if defined(NOT_DYNAMORIO_CORE)
|
||||
# include "dr_project_wide_defines.h"
|
||||
# define ASSERT(x)
|
||||
# define ASSERT_NOT_REACHED()
|
||||
# define ASSERT_NOT_IMPLEMENTED(x)
|
||||
# define DODEBUG(x)
|
||||
# define DOCHECK(n, x)
|
||||
# define DECLARE_NEVERPROT_VAR(var, ...) var = __VA_ARGS__;
|
||||
# define ALIGN_BACKWARD(x, alignment) (((ULONG_PTR)x) & (~((alignment) - 1)))
|
||||
# define PAGE_SIZE 4096
|
||||
#else
|
||||
/* we include globals.h mainly for ASSERT, even though we're
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
#ifndef _UTILS_H_
|
||||
#define _UTILS_H_
|
||||
|
||||
#include "dr_project_wide_defines.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@@ -178,15 +180,6 @@ extern "C" {
|
||||
# define IF_DRMEM_ELSE(x, y) y
|
||||
#endif
|
||||
|
||||
#define ALIGNED(x, alignment) ((((ptr_uint_t)x) & ((alignment) - 1)) == 0)
|
||||
#define ALIGN_BACKWARD(x, alignment) (((ptr_uint_t)x) & (~((alignment) - 1)))
|
||||
#define ALIGN_FORWARD(x, alignment) \
|
||||
((((ptr_uint_t)x) + ((alignment) - 1)) & (~((alignment) - 1)))
|
||||
#define ALIGN_MOD(addr, size, alignment) \
|
||||
((((ptr_uint_t)addr) + (size) - 1) & ((alignment) - 1))
|
||||
#define CROSSES_ALIGNMENT(addr, size, alignment) \
|
||||
(ALIGN_MOD(addr, size, alignment) < (size) - 1)
|
||||
|
||||
#ifndef TESTANY
|
||||
# define TEST(mask, var) (((mask) & (var)) != 0)
|
||||
# define TESTANY TEST
|
||||
|
||||
@@ -31,16 +31,7 @@
|
||||
#define _LIBDWARF_H_
|
||||
|
||||
#ifdef _WIN32
|
||||
/* VS2010 has stdint.h but not VS2008 */
|
||||
typedef INT_PTR off_t;
|
||||
typedef unsigned __int64 uint64_t;
|
||||
typedef unsigned int uint32_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef unsigned char uint8_t;
|
||||
typedef __int64 int64_t;
|
||||
typedef int int32_t;
|
||||
typedef short int16_t;
|
||||
typedef char int8_t;
|
||||
# include <stdint.h>
|
||||
# ifdef __cplusplus
|
||||
# define __BEGIN_DECLS extern "C" {
|
||||
# define __END_DECLS }
|
||||
@@ -316,7 +307,7 @@ typedef struct Dwarf_Relocation_Data_s {
|
||||
unsigned char drd_length;
|
||||
Dwarf_Unsigned drd_offset;
|
||||
Dwarf_Unsigned drd_symbol_index;
|
||||
} * Dwarf_Relocation_Data;
|
||||
} *Dwarf_Relocation_Data;
|
||||
|
||||
#define DWARF_DRD_BUFFER_VERSION 2
|
||||
|
||||
@@ -424,7 +415,7 @@ typedef void (*Dwarf_Handler)(Dwarf_Error, Dwarf_Ptr);
|
||||
#define DW_DLV_OK 0
|
||||
#define DW_DLV_ERROR 1
|
||||
#define DW_DLV_BADADDR NULL
|
||||
#define DW_DLV_NOCOUNT ((Dwarf_Signed)-1)
|
||||
#define DW_DLV_NOCOUNT ((Dwarf_Signed) - 1)
|
||||
|
||||
/*
|
||||
* Access modes.
|
||||
|
||||
@@ -69,8 +69,6 @@ static uint verbose = 0;
|
||||
# define NOTIFY(...) /* nothing */
|
||||
#endif
|
||||
|
||||
#define ALIGNED(x, alignment) ((((ptr_uint_t)x) & ((alignment) - 1)) == 0)
|
||||
|
||||
/* We rely on being able to clobber this register at call sites. */
|
||||
/* At return, we assume we can clobber caller-saved regs not used for return values. */
|
||||
#ifdef ARM
|
||||
|
||||
+4
-5
@@ -35,11 +35,15 @@
|
||||
#ifndef EXT_UTILS_H
|
||||
#define EXT_UTILS_H
|
||||
|
||||
#include "dr_project_wide_defines.h"
|
||||
|
||||
/* TODO i#8001: Move these to dr_project_wide_defines.h. */
|
||||
#define BUFFER_SIZE_BYTES(buf) sizeof(buf)
|
||||
#define BUFFER_SIZE_ELEMENTS(buf) (BUFFER_SIZE_BYTES(buf) / sizeof(buf[0]))
|
||||
#define BUFFER_LAST_ELEMENT(buf) buf[BUFFER_SIZE_ELEMENTS(buf) - 1]
|
||||
#define NULL_TERMINATE_BUFFER(buf) BUFFER_LAST_ELEMENT(buf) = 0
|
||||
|
||||
/* TODO i#8001: Move these to dr_project_wide_defines.h. */
|
||||
/* check if all bits in mask are set in var */
|
||||
#define TESTALL(mask, var) (((mask) & (var)) == (mask))
|
||||
/* check if any bit in mask is set in var */
|
||||
@@ -47,9 +51,4 @@
|
||||
/* check if a single bit is set in var */
|
||||
#define TEST TESTANY
|
||||
|
||||
#define ALIGNED(x, alignment) ((((ptr_uint_t)x) & ((alignment) - 1)) == 0)
|
||||
#define ALIGN_FORWARD(x, alignment) \
|
||||
((((ptr_uint_t)x) + ((alignment) - 1)) & (~((alignment) - 1)))
|
||||
#define ALIGN_BACKWARD(x, alignment) (((ptr_uint_t)x) & (~((ptr_uint_t)(alignment) - 1)))
|
||||
|
||||
#endif /* EXT_UTILS_H */
|
||||
|
||||
+1
-6
@@ -34,6 +34,7 @@
|
||||
#ifndef _DETERMINA_SHAREUTILS_H_
|
||||
#define _DETERMINA_SHAREUTILS_H_
|
||||
|
||||
#include "dr_project_wide_defines.h"
|
||||
#include "share.h"
|
||||
#include "dr_config.h"
|
||||
#include "our_tchar.h"
|
||||
@@ -441,12 +442,6 @@ show_all_events();
|
||||
|
||||
#endif /* DEBUG */
|
||||
|
||||
/* alignment helpers, alignment must be power of 2 */
|
||||
#define ALIGNED(x, alignment) ((((INT_PTR)x) & ((alignment) - 1)) == 0)
|
||||
#define ALIGN_BACKWARD(x, alignment) (((INT_PTR)x) & (~((alignment) - 1)))
|
||||
#define ALIGN_FORWARD(x, alignment) \
|
||||
((((INT_PTR)x) + ((alignment) - 1)) & (~((alignment) - 1)))
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -36,6 +36,8 @@
|
||||
|
||||
/* Common definitions for test suite clients. */
|
||||
|
||||
#include "dr_project_wide_defines.h"
|
||||
|
||||
/* Ignore any PAGE_SIZE provided by the tool chain and define a new version
|
||||
* using dr_api.h.
|
||||
*/
|
||||
@@ -68,13 +70,6 @@
|
||||
#define DR_ASSERT_MSG ASSERT_MSG
|
||||
#define DR_ASSERT ASSERT
|
||||
|
||||
/* Standard pointer-width integer alignment macros. Not provided by dr_api.h.
|
||||
*/
|
||||
#define ALIGN_BACKWARD(x, alignment) (((ptr_uint_t)x) & (~((ptr_uint_t)(alignment) - 1)))
|
||||
#define ALIGN_FORWARD(x, alignment) \
|
||||
((((ptr_uint_t)x) + (((ptr_uint_t)alignment) - 1)) & (~(((ptr_uint_t)alignment) - 1)))
|
||||
#define ALIGNED(x, alignment) ((((ptr_uint_t)x) & ((alignment) - 1)) == 0)
|
||||
|
||||
/* Xref i#302 */
|
||||
#define POINTER_OVERFLOW_ON_ADD(ptr, add) \
|
||||
(((ptr_uint_t)(ptr)) + (add) < ((ptr_uint_t)(ptr)))
|
||||
|
||||
+2
-5
@@ -42,6 +42,7 @@
|
||||
#define _WIN32_WINNT 0x0600
|
||||
|
||||
#define _GNU_SOURCE 1 /* for REG_RIP, etc. */
|
||||
#include "dr_project_wide_defines.h"
|
||||
#include "configure.h"
|
||||
#include "drlibc.h"
|
||||
#include <stdarg.h>
|
||||
@@ -294,6 +295,7 @@ page_size(void)
|
||||
# define NOINLINE __attribute__((__noinline__))
|
||||
#endif
|
||||
|
||||
/* TODO i#8001: Move these to dr_project_wide_defines.h. */
|
||||
/* convenience macros for secure string buffer operations */
|
||||
#define BUFFER_SIZE_BYTES(buf) sizeof(buf)
|
||||
#define BUFFER_SIZE_ELEMENTS(buf) (BUFFER_SIZE_BYTES(buf) / sizeof(buf[0]))
|
||||
@@ -319,11 +321,6 @@ typedef enum {
|
||||
COPY_CROSS_PAGE,
|
||||
} Copy_Mode;
|
||||
|
||||
#define ALIGN_BACKWARD(x, alignment) (((ptr_uint_t)x) & (~((ptr_uint_t)(alignment) - 1)))
|
||||
#define ALIGN_FORWARD(x, alignment) \
|
||||
((((ptr_uint_t)x) + (((ptr_uint_t)alignment) - 1)) & (~(((ptr_uint_t)alignment) - 1)))
|
||||
#define ALIGNED(x, alignment) ((((ptr_uint_t)x) & ((alignment) - 1)) == 0)
|
||||
|
||||
#ifdef UNIX
|
||||
# ifndef MAP_ANONYMOUS
|
||||
# define MAP_ANONYMOUS MAP_ANON /* MAP_ANON on Mac */
|
||||
|
||||
+1
-7
@@ -35,6 +35,7 @@
|
||||
# error 64-bit not yet supported (issue #118)
|
||||
#endif
|
||||
|
||||
#include "dr_project_wide_defines.h"
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
@@ -57,13 +58,6 @@ static int verbose = 1;
|
||||
|
||||
#define WARN(...) INFO(0, __VA_ARGS__)
|
||||
|
||||
/* alignment helpers */
|
||||
#define ALIGNED(x, alignment) ((((uint)x) & ((alignment) - 1)) == 0)
|
||||
#define ALIGN_FORWARD(x, alignment) \
|
||||
((((uint)x) + ((alignment) - 1)) & (~((alignment) - 1)))
|
||||
#define ALIGN_BACKWARD(x, alignment) (((uint)x) & (~((alignment) - 1)))
|
||||
#define PAD(length, alignment) (ALIGN_FORWARD((length), (alignment)) - (length))
|
||||
|
||||
/* check if all bits in mask are set in var */
|
||||
#define TESTALL(mask, var) (((mask) & (var)) == (mask))
|
||||
/* check if any bit in mask is set in var */
|
||||
|
||||
Reference in New Issue
Block a user