1998-10-20 Martin Baulig <martin@home-of-linux.org> * include/glibtop/proc_signal.h: Use a 2-element-array of type `u_int64_t' for all signal masks instead of just scalar numbers. This avoids problems on systems with more than 64 signals. If there is any operating system out there with even more than 128 signals, we can simply increase the number of array elements here. [NOTE for people porting libgtop: Please use all 64 bits of the `u_int64_t' and not just 32 - the signal number (as it is used in calls to kill () ...) should be a bit-index into this field; if a process ignores for instance signal 64, it has the 0-bit of sigcatch[1] set, if it ignores 63, this is the 63-bit of sigcatch[0] and so on ... The mapping between signal numbers and their names is done via the glibtop_sys_siglist [] field which should be declared in sysdeps/@sysdeps_dir@/siglist.c - see linux for an example. ] * features.def: It's now safe to put things like `loadavg[3]' here - the awk skripts should correctly threat this as an array.
142 lines
3.9 KiB
Awk
142 lines
3.9 KiB
Awk
BEGIN {
|
|
print "/* guile.c */";
|
|
print "/* This is a generated file. Please modify `guile.awk' */";
|
|
print "";
|
|
|
|
print "#include <glibtop.h>";
|
|
print "#include <glibtop/xmalloc.h>";
|
|
print "#include <glibtop/sysdeps.h>";
|
|
print "#include <glibtop/union.h>";
|
|
print "";
|
|
print "#include <guile/gh.h>";
|
|
|
|
print "";
|
|
|
|
convert["long"] = "gh_long2scm ";
|
|
convert["ulong"] = "gh_ulong2scm ";
|
|
convert["double"] = "gh_double2scm";
|
|
convert["str"] = "gh_str02scm ";
|
|
convert["char"] = "gh_char2scm ";
|
|
|
|
backconv["int"] = "gh_scm2long";
|
|
backconv["pid_t"] = "gh_scm2ulong";
|
|
backconv["long"] = "gh_scm2long";
|
|
backconv["ulong"] = "gh_scm2ulong";
|
|
}
|
|
|
|
function make_output(line) {
|
|
split (line, line_fields, /\|/);
|
|
retval = line_fields[1];
|
|
element_def = line_fields[3];
|
|
feature = line_fields[2];
|
|
param_def = line_fields[4];
|
|
|
|
sub(/^@/,"",feature);
|
|
features[feature] = feature;
|
|
|
|
total_nr_params = 0;
|
|
|
|
if (param_def == "string") {
|
|
call_param = ", gh_scm2newstr( "line_fields[5]", NULL)";
|
|
param_decl = "SCM "line_fields[5];
|
|
total_nr_params = 1;
|
|
} else {
|
|
call_param = "";
|
|
param_decl = "";
|
|
nr_params = split (param_def, params, /:/);
|
|
for (param = 1; param <= nr_params; param++) {
|
|
list = params[param];
|
|
type = params[param];
|
|
sub(/\(.*/, "", type);
|
|
sub(/^.*\(/, "", list); sub(/\)$/, "", list);
|
|
count = split (list, fields, /,/);
|
|
total_nr_params = total_nr_params + count;
|
|
for (field = 1; field <= count; field++) {
|
|
if (param_decl != "")
|
|
param_decl = param_decl", ";
|
|
param_decl = param_decl"SCM "fields[field];
|
|
call_param = call_param", "backconv[type]" ("fields[field]")";
|
|
}
|
|
}
|
|
if (param_decl == "")
|
|
param_decl = "void";
|
|
}
|
|
|
|
nr_params_field[feature] = total_nr_params;
|
|
|
|
feature_name = feature; sub(/_/,"-",feature_name);
|
|
output = "SCM_PROC (s_"feature", \"glibtop-get-"feature_name"\",";
|
|
output = output" "nr_params_field[feature]", 0, 0, ";
|
|
output = output"glibtop_guile_get_"feature");\n\n";
|
|
|
|
output = output"static SCM\nglibtop_guile_get_"feature" ("param_decl")\n{\n";
|
|
|
|
output = output"\tglibtop_"feature" "feature";\n";
|
|
if (retval != "void")
|
|
output = output"\t"retval" retval;\n";
|
|
if (feature ~ /^proclist$/)
|
|
output = output"\tunsigned i;\n";
|
|
output = output"\tSCM list;\n\n";
|
|
|
|
if (retval != "void")
|
|
prefix="retval = ";
|
|
else
|
|
prefix="";
|
|
|
|
output = output"\t"prefix"glibtop_get_"feature" (&"feature""call_param");\n\n";
|
|
|
|
output = output"\tlist = gh_list (gh_ulong2scm ("feature".flags),\n\t\t\t";
|
|
|
|
nr_elements = split (element_def, elements, /:/);
|
|
for (element = 1; element <= nr_elements; element++) {
|
|
list = elements[element];
|
|
type = elements[element];
|
|
sub(/\(.*/, "", type);
|
|
sub(/^.*\(/, "", list); sub(/\)$/, "", list);
|
|
count = split (list, fields, /,/);
|
|
for (field = 1; field <= count; field++) {
|
|
if (fields[field] ~ /^(\w+)\[([0-9]+)\]$/) {
|
|
split(fields[field], field_parts, /\[/);
|
|
fields[field] = field_parts[1];
|
|
sub(/\]/, "", field_parts[2]);
|
|
number = field_parts[2];
|
|
for (nr = 0; nr < number; nr++) {
|
|
output = output""convert[type]" ("feature"."fields[field]" ["nr"]),\n\t\t\t";
|
|
}
|
|
} else {
|
|
output = output""convert[type]" ("feature"."fields[field]"),\n\t\t\t";
|
|
}
|
|
}
|
|
}
|
|
output = output"SCM_UNDEFINED);\n";
|
|
|
|
print output;
|
|
|
|
if (feature ~ /^proclist$/) {
|
|
print "\tif (retval == NULL)";
|
|
print "\t\treturn list;";
|
|
print "";
|
|
print "\tfor (i = 0; i < proclist.number; i++)";
|
|
print "\t\tlist = scm_append";
|
|
print "\t\t\t(gh_list (list,";
|
|
print "\t\t\t\t gh_list (gh_ulong2scm ((unsigned long) retval [i])),";
|
|
print "\t\t\t\t SCM_UNDEFINED));";
|
|
print "";
|
|
print "\tglibtop_free (retval);\n";
|
|
}
|
|
|
|
print "\treturn list;";
|
|
print "}";
|
|
print "";
|
|
}
|
|
|
|
/^[^#]/ { make_output($0) }
|
|
|
|
END {
|
|
print "void";
|
|
print "glibtop_boot_guile (void)";
|
|
print "{";
|
|
print "#include \"guile.x\"";
|
|
print "}";
|
|
}
|