Raymond Toy pushed to branch issue-386-generate-def-unix-error at cmucl / cmucl

Commits:

2 changed files:

Changes:

  • bin/create-errno.sh
    ... ... @@ -5,34 +5,76 @@
    5 5
     # definitions of all the Unix errno values.
    
    6 6
     #
    
    7 7
     
    
    8
    +usage ()
    
    9
    +{
    
    10
    +    cat <<EOF
    
    11
    +create-erno.sh [-h?DS]
    
    12
    +    -h    This help
    
    13
    +    -?    This help
    
    14
    +    -D	  Do not auto-generate; use default
    
    15
    +
    
    16
    +    -S    Show the resulting generated file; the file is still created.
    
    17
    +
    
    18
    +Auto-generates, if possible, the file src/code/errno.lisp that
    
    19
    +contains the def-unix-error forms.
    
    20
    +EOF
    
    21
    +    exit 0
    
    22
    +}
    
    23
    +
    
    24
    +while getopts "h?DS" arg
    
    25
    +do
    
    26
    +    case $arg in
    
    27
    +	h) usage ;;
    
    28
    +	\?) usage ;;
    
    29
    +	D) DEFAULT=yes ;;
    
    30
    +	S) SHOW=yes ;;
    
    31
    +    esac
    
    32
    +done
    
    33
    +
    
    8 34
     # Where the output should go.
    
    9 35
     OUTPUT="src/code/errno.lisp"
    
    10 36
     
    
    11
    -# Copy the main errno template to the output.  The template is a lisp
    
    12
    -# file so we can read and modify it more easily.
    
    13
    -cat bin/errno-template.lisp > $OUTPUT
    
    14
    -
    
    15
    -# Create appropriate DEF-UNIX-ERROR forms by reading header files
    
    16
    -# containing the C definitions.
    
    37
    +# Template file containing the default def-unix-error forms and other
    
    38
    +# support code.
    
    39
    +TEMPLATE="bin/errno-template.lisp"
    
    17 40
     
    
    18 41
     # Set ERRNO_FILES to the files where we can find errno definitions.
    
    19
    -case `uname -s` in
    
    20
    -    Linux) ERRNO_FILES=/usr/include/asm-generic/errno*.h
    
    21
    -	   ;;
    
    22
    -    Darwin) ERRNO_FILES=/usr/include/sys/errno.h
    
    23
    -	    ;;
    
    24
    -    SunOS) ERRNO_FILES=/usr/include/sys/errno.h
    
    25
    -	   ;;
    
    26
    -esac
    
    27
    -
    
    28
    -awk -f bin/create-def-unix-error.awk ${ERRNO_FILES} >> $OUTPUT
    
    29
    -
    
    30
    -# The tail was also copied from code/unix.lisp.  It's needed to tell
    
    31
    -# Lisp about the errno values.
    
    32
    -cat >>$OUTPUT <<EOF
    
    33
    -;;; End auto-generated forms, if any.
    
    34
    -
    
    35
    -;;;
    
    36
    -;;; And now for something completely different ...
    
    37
    -(emit-unix-errors)
    
    42
    +if [ -z "$DEFAULT" ]; then
    
    43
    +    case `uname -s` in
    
    44
    +	Linux) ERRNO_FILES=/usr/include/asm-generic/errno*.h
    
    45
    +	       ;;
    
    46
    +	Darwin) ERRNO_FILES=/usr/include/sys/errno.h
    
    47
    +		;;
    
    48
    +	SunOS) ERRNO_FILES=/usr/include/sys/errno.h
    
    49
    +	       ;;
    
    50
    +    esac
    
    51
    +fi
    
    52
    +
    
    53
    +if [ -z "$ERRNO_FILES" ]; then
    
    54
    +    # Copy the main errno template to the output.  The template is a lisp
    
    55
    +    # file so we can read and modify it more easily.
    
    56
    +    cat "$TEMPLATE" > $OUTPUT
    
    57
    +else
    
    58
    +    # We can autogenerate the def-unix-error forms.  Copy just the
    
    59
    +    # initial part of the template, up to the first def-unix-error
    
    60
    +    # form.
    
    61
    +    sed '/^(def-unix-error ESUCCESS/q' "$TEMPLATE" > $OUTPUT
    
    62
    +    cat >> $OUTPUT <<EOF
    
    63
    +
    
    64
    +;; Autogenerated def-unix-error forms
    
    38 65
     EOF
    
    66
    +    
    
    67
    +    # Create appropriate DEF-UNIX-ERROR forms by reading header files
    
    68
    +    # containing the C definitions.
    
    69
    +
    
    70
    +    awk -f bin/create-def-unix-error.awk ${ERRNO_FILES} >> $OUTPUT
    
    71
    +
    
    72
    +    # The tail was also copied from code/unix.lisp.  It's needed to tell
    
    73
    +    # Lisp about the errno values.
    
    74
    +    sed '1,/^;;; End of default/d' "$TEMPLATE" >> $OUTPUT
    
    75
    +fi
    
    76
    +
    
    77
    +# If -S option given, cat the output file to stdout
    
    78
    +if [ -n "$SHOW" ]; then
    
    79
    +    cat $OUTPUT
    
    80
    +fi

  • bin/errno-template.lisp
    ... ... @@ -44,8 +44,11 @@
    44 44
     ;;; 
    
    45 45
     (def-unix-error ESUCCESS 0 _N"Successful")
    
    46 46
     
    
    47
    -#-(or linux darwin svr4) 
    
    48
    -(progn
    
    47
    +;;; Do NOT modify the ESUCCESS form above.  bin/create-errno.sh
    
    48
    +;;; depends on it.
    
    49
    +
    
    50
    +;;; Default errno values.  These are used only if we could not
    
    51
    +;;; auto-generate these forms.
    
    49 52
     (def-unix-error EPERM 1 _N"Operation not permitted")
    
    50 53
     (def-unix-error ENOENT 2 _N"No such file or directory")
    
    51 54
     (def-unix-error ESRCH 3 _N"No such process")
    
    ... ... @@ -138,7 +141,11 @@
    138 141
     ;;; VICE
    
    139 142
     (def-unix-error EVICEERR 70 _N"Remote file system error _N")
    
    140 143
     (def-unix-error EVICEOP 71 _N"syscall was handled by Vice")
    
    141
    -)
    
    142 144
     
    
    143
    -;;; Auto-generated forms, if any, follow here.
    
    145
    +;;; Do NOT modify the line below.  bin/create-errno.sh depends on it.
    
    146
    +
    
    147
    +;;; End of default def-unix-error forms
    
    148
    +
    
    149
    +;;; And now for something completely different ...
    
    150
    +(emit-unix-errors)
    
    144 151