PyObject *py_rxgen_received_abort(struct rx_call *call)
{
const struct kafs_abort_list *entry;
+ const char *msg;
PyObject *ex;
entry = bsearch((void *)(unsigned long)call->abort_code,
sizeof(kafs_abort_map[0]),
py_rxgen_received_abort_cmp);
- if (entry)
+ if (entry) {
ex = entry->obj;
- else
+ msg = entry->msg;
+ } else {
ex = kafs_remote_abort;
+ msg = NULL;
+ }
- return PyErr_Format(ex, "Aborted %u", call->abort_code);
+ if (msg)
+ return PyErr_Format(ex, "Aborted %u: %s", call->abort_code, msg);
+ else
+ return PyErr_Format(ex, "Aborted %u", call->abort_code);
}
print PYOUT "\n";
print PYHDR "extern struct kafs_abort_list kafs_abort_map[", $abort_count, "];\n";
- my %abort_table_map = ();
my $index = 0;
print PYOUT "struct kafs_abort_list kafs_abort_map[", $abort_count, "] = {\n";
foreach my $id (sort {$a <=> $b} keys(%abort_ids)) {
- my $name = $abort_ids{$id};
- print PYOUT "\t{ .id = ", $name, " }, /* ", $id, " */\n";
- $abort_table_map{$name} = $index++;
+ my $abort = $abort_ids{$id};
+ print PYOUT "\t{ .id = ", $abort->{sym};
+ print PYOUT ", .msg = \"", $abort->{msg}, "\"" if ($abort->{msg});
+ print PYOUT " }, /* ", $abort->{id}, " */\n";
+ $abort->{index} = $index++;
}
print PYOUT "};\n\n";
foreach $_ (sort(keys(%packages))) {
my $pkg = $packages{$_};
- my $codes = $pkg->{abort_codes};
- next unless (@{$codes});
+ my $abort_codes = $pkg->{abort_codes};
+ next unless (@{$abort_codes});
my $pkg_abort = $pkg->{name} . "Abort";
my $pkg_sym = "kafs_" . $pkg->{name} . "_abort";
print PYOUT "\tPy_INCREF(", $pkg_sym, ");\n";
print PYOUT "\tPyModule_AddObject(m, \"", $pkg_abort, "\", ", $pkg_sym, ");\n";
- foreach my $code (sort(@{$codes})) {
- my $code_abort = "Abort" . $code;
- my $code_sym = "kafs_abort_map[" . $abort_table_map{$code} . "].obj";
+ foreach my $abort (sort { $a->{id} <=> $b->{id}; } @{$abort_codes}) {
+ my $abort_name = "Abort" . $abort->{sym};
+ my $abort_var = "kafs_abort_map[" . $abort->{index} . "].obj";
print PYOUT "\n";
- print PYOUT "\t", $code_sym, " = PyErr_NewException(\"kafs.", $code_abort, "\", ", $pkg_sym, ", NULL);\n";
- print PYOUT "\tif (!", $code_sym, ")\n";
+ print PYOUT "\t", $abort_var, " = PyErr_NewException(\"kafs.", $abort_name, "\", ", $pkg_sym, ", NULL);\n";
+ print PYOUT "\tif (!", $abort_var, ")\n";
print PYOUT "\t\treturn NULL;\n";
- print PYOUT "\tPy_INCREF(", $code_sym, ");\n";
- print PYOUT "\tPyModule_AddObject(m, \"", $code_abort, "\", ", $code_sym, ");\n";
+ print PYOUT "\tPy_INCREF(", $abort_var, ");\n";
+ print PYOUT "\tPyModule_AddObject(m, \"", $abort_name, "\", ", $abort_var, ");\n";
}
}
$error_codes = 0 if ($line eq "");
# Discard comments
+ my $line_comment = "";
find_comment_terminator:
if ($comment_discard) {
# Find the terminator for a comment we're discarding
- if ($line =~ m@.*[*]/(.*)@) {
- $line = $pre_comment . $1;
+ if ($line =~ m@(.*)[*]/(.*)@) {
+ $line_comment = $1;
+ $line = $pre_comment . $2;
$comment_discard = 0;
} else {
$line = $pre_comment;
$line =~ s!\t!!g;
next if (!$line);
+ $line_comment =~ s/^\s+//;
+ $line_comment =~ s/\s+$//;
+ $line_comment =~ s/\s+/ /g;
+
#print "'$line'\n";
# Complain about #defines
die $where, ": Duplicate abort ID"
if (exists $abort_ids{$v});
- push @{$abort_codes}, $c;
- $abort_syms{$c} = $v;
- $abort_ids{$v} = $c;
+
+ my %abort = (
+ sym => $c,
+ id => $v,
+ msg => $line_comment,
+ );
+
+ push @{$abort_codes}, \%abort;
+ $abort_syms{$c} = \%abort;
+ $abort_ids{$v} = \%abort;
$abort_count++;
}
next;