modularize.h
3.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/*
* Copyright (C) 1996-1998 by the Board of Trustees
* of Leland Stanford Junior University.
*
* This file is part of the SimOS distribution.
* See LICENSE file for terms of the license.
*
*/
/*
* @TITLE "modularize.h"
*
* This file is supposed to include all the typedefs, macros
* and function headers that allows diskdevice.c to compile
* independently of proteus.
*
*/
/* $Id: modularize.h,v 1.1.1.1 2002/05/29 01:09:11 blythe Exp $ */
#ifndef MODULARIZE_H
#define MODULARIZE_H
/* ---- including header files ---- */
#include <stdio.h>
#include <math.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/file.h>
#include <malloc.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <sim_error.h>
/* ---- constant declarations ---- */
#define TRUE 1
#define FALSE 0
#define ERROR -1 /* misc error */
#define FATAL -9 /* fatal error */
/* ----global variables ---- */
/* none */
/* ---- macros for debugging ---- */
#define DEBUG1 if (1)
#define DEBUG0 if (0)
/* ======================================================================= */
/* Redefinition of the macros or constants previously available in
porteus main program. */
#define PRIVATE static
#define ulong unsigned long
#define CYCLE_COUNTING_OFF
#define CYCLE_COUNTING_ON
#define INVARIANT2(a,b) {if (!(a)) {fprintf(stderr, b); ASSERT(0);}}
#define INVARIANT3(a,b,c) {if (!(a)) {fprintf(stderr, b, c); ASSERT(0);}}
#define INVARIANT4(a,b,c,d) {if (!(a)) {fprintf(stderr, b, c, d); ASSERT(0);}}
#ifndef SOLO
extern double diskTICSperMSEC;
#define TICSperMSEC (diskTICSperMSEC)
#define MSECperTIC (1.0/diskTICSperMSEC)
#else
#define TICSperMSEC 25000.0 /* assuming 25MHz */
#define MSECperTIC (1/25000.0) /* assuming 25MHz */
#endif
#define UlongAbsDiff(a,b) ((a) >(b)? ((a)-(b)):((b)-(a)))
#define define_local(a, b, c) (*(a) = (b))
/* though only consists of 0 and 1 */
typedef int boolean;
/* definition for TICS */
#ifdef LONG_LONG_TIME
typedef uint64 TICS;
#else
typedef unsigned long TICS;
#endif
#ifdef LONG_LONG_TIME
# define MAXTIME (TICS)(0xffffffffffffffffLL)
#else
# define MAXTIME (TICS)(0xffffffffL)
#endif
#define NEVER MAXTIME
/* Redefinition of functions in the timing module */
TICS InitTime(void);
TICS GetTime(void);
TICS max(TICS one, TICS two);
TICS min(TICS one, TICS two);
void WaitTime(TICS);
void WaitDuration(TICS);
char* time_print(TICS t);
char* timep_print(TICS *t);
/* ======================================================================= */
/* this is the global structure that contains information about time */
typedef struct timestruct
{
TICS currenttime;
} timestruct;
/* this is to be used by the event manager */
void thread_suspend(int tid);
#define MY_TID 0xFF /* just a dummy used as a thread ID */
#define MY_STID 0xFF /* another dummy */
#ifndef SOLO
extern void thread_wakeup(int disk,int tid);
extern void thread_suspend_continue(int tid, void (*routine)(void *), void *arg);
#endif
/* ---------------- for REQUEST() only ------------------- */
/* maximum heap size */
#define HEAP_MAX 40
#define CURR_PROCESSOR 5 /* dummy */
#define NO_OF_DISKS 1000 /* plenty */
#define INDEX_EVENT(a,b,c) {}
#define INDEX_TIME_EVENT(a,b,c,d) {}
#define SUM_ARRAY_METRIC(a, b, c) {}
#define AVG_ARRAY_METRIC(a,b,c) {}
#define STDDEV_ARRAY_METRIC(a,b,c,d) {}
typedef char *UserData;
/* ---- typedef for function pointer to functions that returns void ---- */
typedef void (*FuncPtr)(int, TICS);
#endif /* only include this file if it is not
previously included */