Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add script to generate list of errno value macros

  • Loading branch information...
commit c76de5a6f04af57d6bc98ed70cf86fea3fd52e7a 1 parent 9918925
@hoelzro hoelzro authored
Showing with 43 additions and 0 deletions.
  1. +43 −0 tools/build/generate-constants.pl
View
43 tools/build/generate-constants.pl
@@ -0,0 +1,43 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+
+use POSIX;
+
+print <<"END_HEADER";
+# DO NOT EDIT THIS FILE.
+#
+# This file is generated automatically from
+# $0
+#
+# Any changes made here will be lost.
+#
+END_HEADER
+
+my @errno_values;
+
+my $max_errno_name_len = 0;
+foreach my $name (sort grep { /^E[A-Z]+$/ } keys %POSIX::) {
+ my $code = POSIX->can($name);
+
+ next unless $code;
+
+ my $value = eval { $code->() };
+
+ next unless defined $value;
+
+ push @errno_values, [ $name, $value ];
+
+ if(length($name) > $max_errno_name_len) {
+ $max_errno_name_len = length($name);
+ }
+}
+
+my $format = ".macro_const POSIX_%-${max_errno_name_len}s %d\n";
+
+foreach my $pair (@errno_values) {
+ my ( $name, $value ) = @$pair;
+
+ printf $format, $name, $value;
+}

0 comments on commit c76de5a

Please sign in to comment.
Something went wrong with that request. Please try again.