akaros/scripts/make_errlist.sh
<<
>>
Prefs
   1#!/bin/bash
   2
   3ERRLIST="tools/compilers/gcc-glibc/glibc-2.19-akaros/sysdeps/akaros/errlist.c"
   4ERRNO_FILE="kern/include/ros/errno.h"
   5
   6echo "// This was automatically generated with make_errlist.sh, do not edit" > $ERRLIST
   7echo ""                                   >> $ERRLIST
   8echo "#include <stddef.h>"                >> $ERRLIST
   9echo ""                                   >> $ERRLIST
  10echo "const char *const _sys_errlist[] =" >> $ERRLIST
  11echo "{"                                  >> $ERRLIST
  12
  13# here's the guts of it.  Get the #define E's, compress the extra tabs, cut to
  14# get from the numbers to the end, remove the aliases (number is EWHATEVER),
  15# then awk it.  The awk script does some fancy formatting.  NF is the number of
  16# items on the line.  The last item on the line is */, which we never print.
  17# The second to last is printed without a trailing space.
  18
  19cat $ERRNO_FILE | ./scripts/parse_errno.sh >> $ERRLIST
  20
  21echo "};"                                 >> $ERRLIST
  22echo ""                                   >> $ERRLIST
  23echo "const int _sys_nerr = sizeof (_sys_errlist) / sizeof (_sys_errlist[0]);" >> $ERRLIST
  24echo ""                                   >> $ERRLIST
  25echo "strong_alias(_sys_errlist,_sys_errlist_internal);"                       >> $ERRLIST
  26echo "strong_alias(_sys_nerr,_sys_nerr_internal);"                             >> $ERRLIST
  27