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 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197
|
/*
* cook - file construction tool
* Copyright (C) 1997, 1999, 2000 Peter Miller;
* All rights reserved.
*
* 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, USA.
*
* MANIFEST: functions to manipulate recipes
*/
#include <cook.h>
#include <dir_part.h>
#include <error_intl.h>
#include <graph/file.h>
#include <graph/file_list.h>
#include <graph/recipe.h>
#include <id.h>
#include <opcode/context.h>
#include <match.h>
#include <mem.h>
#include <option.h>
#include <os_interface.h>
#include <recipe.h>
#include <star.h>
#include <stmt.h>
#include <trace.h>
/*
* NAME
* graph_recipe_new
*
* SYNOPSIS
* graph_recipe_ty *graph_recipe_new(recipe_ty *);
*
* DESCRIPTION
* The graph_recipe_new function is used to allocate a new graph
* recipe instance in dynamic memory.
*
* RETURNS
* graph_recipe_ty *
*
* CAVEAT
* Use graph_recipe_delete when you are done with it.
*/
graph_recipe_ty *
graph_recipe_new(rp)
recipe_ty *rp;
{
graph_recipe_ty *grp;
static int id;
trace(("graph_recipe_new()\n{\n"/*}*/));
grp = mem_alloc(sizeof(graph_recipe_ty));
grp->reference_count = 1;
grp->id = ++id;
grp->rp = recipe_copy(rp);
grp->mp = 0;
grp->input = graph_file_list_nrc_new();
grp->output = graph_file_list_nrc_new();
grp->input_satisfied = 0;
grp->input_uptodate = 0;
grp->ocp = 0;
grp->single_thread = 0;
grp->host_binding = 0;
grp->multi_forced = 0;
trace(("return %08lX;\n", (long)grp));
trace((/*{*/"}\n"));
return grp;
}
/*
* NAME
* graph_recipe_delete
*
* SYNOPSIS
* void graph_recipe_delete(graph_recipe_ty *);
*
* DESCRIPTION
* The graph_recipe_delete function is used to release the
* resources held by a graph recipe instance in dynamic memory.
*/
void
graph_recipe_delete(grp)
graph_recipe_ty *grp;
{
trace(("graph_recipe_delete(grp = %08lX)\n{\n"/*}*/, (long)grp));
assert(grp->reference_count > 0);
grp->reference_count--;
if (grp->reference_count > 0)
{
trace((/*{*/"}\n"));
return;
}
recipe_delete(grp->rp);
if (grp->mp)
{
match_delete(grp->mp);
grp->mp = 0;
}
graph_file_list_nrc_delete(grp->input);
graph_file_list_nrc_delete(grp->output);
if (grp->ocp)
opcode_context_delete(grp->ocp);
if (grp->single_thread)
string_list_delete(grp->single_thread);
if (grp->host_binding)
string_list_delete(grp->host_binding);
mem_free(grp);
trace((/*{*/"}\n"));
}
/*
* NAME
* graph_recipe_copy
*
* SYNOPSIS
* graph_recipe_ty *graph_recipe_copy(graph_recipe_ty *);
*
* DESCRIPTION
* The graph_recipe_copy function is used to copy a graph recipe
* instance in dynamic memory.
*/
graph_recipe_ty *
graph_recipe_copy(grp)
graph_recipe_ty *grp;
{
assert(grp->reference_count > 0);
grp->reference_count++;
return grp;
}
/*
* NAME
* graph_recipe_getpid
*
* SYNOPSIS
* int graph_recipe_getpid(graph_recipe_ty *);
*
* DESCRIPTION
* The graph_recipe_getpid function is used to get the process-id
* of the process to wait for.
*
* CAVEAT
* Must only be used when graph_recipe_run returns
* graph_walk_status_wait.
*/
int
graph_recipe_getpid(grp)
graph_recipe_ty *grp;
{
assert(grp);
assert(grp->ocp);
return opcode_context_getpid(grp->ocp);
}
/*
* NAME
* graph_recipe_waited
*
* SYNOPSIS
* void graph_recipe_waited(graph_recipe_ty *, int);
*
* DESCRIPTION
* The graph_recipe_waited function is used to set the exit status
* after a waiting graph walk is about to resume.
*/
void
graph_recipe_waited(grp, status)
graph_recipe_ty *grp;
int status;
{
assert(grp);
assert(grp->ocp);
opcode_context_waited(grp->ocp, status);
}
|