资源简介
duma_2_5_15.tar.gz crosstool-ng编译需要的工具
代码片段和文件信息
/*
* DUMA - Red-Zone memory allocator.
*
* Copyright (C) 2006 Michael Eddington
* Copyright (C) 2002-2008 Hayati Ayguen Procitec GmbH
* Copyright (C) 1987-1999 Bruce Perens
*
* License: GNU GPL (GNU General Public License see COPYING-GPL)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not write to the Free Software
* Foundation Inc. 59 Temple Place Suite 330 Boston MA 02111-1307 USA
*
*
* FILE CONTENTS:
* --------------
* This is a small tool to generate the “duma_config.h“ configuration file.
* Its purpose is to allow fixed size memory allocation on stack which can
* get protected calling page protection functions.
* Also its nice for the user to be able to see the page size.
*/
#include
#include
#include
#include
#ifdef _MSC_VER
#include
#endif
#ifndef WIN32
#include
#include
#include
#else
#define WIN32_LEAN_AND_MEAN 1
#include
#include se.h>
#ifndef __CYGWIN__
/* already defined in cygwin headers */
typedef LPVOID caddr_t;
typedef unsigned u_int;
#endif
#endif
/*
* retrieve page size
* size_t Page_Size(void)
*/
static size_t
Page_Size(void)
{
#if defined(WIN32)
SYSTEM_INFO SystemInfo;
GetSystemInfo( &SystemInfo );
return (size_t)SystemInfo.dwPageSize;
#elif defined(_SC_PAGESIZE)
return (size_t)sysconf(_SC_PAGESIZE);
#elif defined(_SC_PAGE_SIZE)
return (size_t)sysconf(_SC_PAGE_SIZE);
#else
/* extern int getpagesize(); */
return getpagesize();
#endif
}
int initattr_ok = 0;
void
#ifdef __GNUC__
__attribute ((constructor))
#endif
init_function(void)
{
initattr_ok = 1;
}
typedef struct
{
int id;
int size;
char *type;
}
DataType_T;
DataType_T sIntTypes[] =
{
{ 0 sizeof(char) “char“ }
{ 1 sizeof(short int) “short int“ }
{ 2 sizeof(int) “int“ }
{ 3 sizeof(long int) “long int“ }
/* add additional compiler specific typer here */
#ifdef _MSC_VER
{ 4 sizeof(__int64) “__int64“ }
#endif
#ifdef __GNUC__
{ 5 sizeof(long long int) “long long int“ }
#endif
};
/* test access to each data type */
void testAlignment(int addrIdx char * buffer int alignment int max_sizeof)
{
int offset;
switch ( sIntTypes[addrIdx].id )
{
case 0:
#define TYPE unsigned char
for(offset=0; offset < max_sizeof; ++offse
评论
共有 条评论