1/* 2 * memtoy.h -- local header template for memory toy/tool 3 */ 4/* 5 * Copyright (c) 2005 Hewlett-Packard, Inc 6 * All rights reserved. 7 */ 8 9/* 10 * This program is free software; you can redistribute it and/or modify 11 * it under the terms of the GNU General Public License as published by 12 * the Free Software Foundation; either version 2 of the License, or 13 * (at your option) any later version. 14 * 15 * This program is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU General Public License for more details. 19 * 20 * You should have received a copy of the GNU General Public License 21 * along with this program; if not, write to the Free Software 22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 23 */ 24#ifndef _MEMTOY_H 25#define _MEMTOY_H 26#include <sys/types.h> 27#include <sys/time.h> 28 29#include <setjmp.h> 30#include <signal.h> 31 32#include "segment.h" 33#include "version.h" 34 35#define BOGUS_SIZE ((size_t)-1) 36 37typedef enum {false=0, true} bool; 38 39/* 40 * program global data 41 */ 42typedef struct global_context { 43 char *program_name; /* argv[0] - for reference in messages */ 44 45 unsigned long options; /* command line options, ... */ 46 47 siginfo_t *siginfo; /* signal info, if signalled != 0 */ 48 char *signame; /* name of signal, if any */ 49 sigjmp_buf sigjmp_env; /* embedded setjmp buffer */ 50 bool sigjmp; /* sigsetjmp is "armed" */ 51 52 size_t pagesize; /* system page size for mmap, ... */ 53 54 int numa_max_node; /* if >0, numa supported */ 55 56 segment_t **seglist; /* list of known segments */ 57 segment_t *seg_avail; /* an available segment */ 58 59 char *cmd_name; /* currently executing command */ 60 61#ifdef _DEBUG 62 unsigned long debug; /* debug enablement flags */ 63#endif 64} glctx_t; 65 66extern glctx_t glctx; 67 68#define OPTION_VERBOSE 0x0001 69#define OPTION_INTERACTIVE 0x0100 70 71/* 72 * Danger, Will Robinson!! -- hardcoded variable 'gcp' 73 */ 74#define set_option(OPT) gcp->options |= (OPTION_##OPT) 75#define clear_option(OPT) gcp->options &= ~(OPION_##OPTT) 76#define is_option(OPT) ((gcp->options & OPTION_##OPT) != 0) 77 78#define show_option(opt, off, on) ( !is_option(opt) ? #off : #on ) 79 80#define signalled(GCP) (GCP->siginfo != NULL) 81 82/* 83 * different between start and end time in microseconds 84 */ 85static unsigned long tv_diff_usec(struct timeval *stp, struct timeval *etp) 86{ 87 return ((1000000L * (etp)->tv_sec + (etp)->tv_usec) - 88 (1000000L * (stp)->tv_sec + (stp)->tv_usec)); 89} 90 91 92/* 93 * memtoy.c 94 */ 95extern void die(int, char*, ... ); 96extern void vprint(char*, ...); 97extern void reset_signal(void); 98extern void wait_for_signal(const char*); 99 100/* 101 * commands.c 102 */ 103extern void process_commands(void); 104extern void wait_for_signal(const char *); 105extern void touch_memory(bool, unsigned long*, size_t); 106 107#endif 108