bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Remove functions, procedures and simple procedures.


From: Flávio Cruz
Subject: Re: [PATCH] Remove functions, procedures and simple procedures.
Date: Sat, 19 Mar 2016 14:09:01 +0100


On 19 March 2016 at 12:35, Samuel Thibault <samuel.thibault@gnu.org> wrote:
Hello,

Flavio Cruz, on Tue 15 Mar 2016 05:31:41 -0400, wrote:
> This has been tested by cross-compiling a base Hurd system to make sure
> these kinds of routines are no longer used.

What is the rationale for removing them?  Will we never need them again?

They are already marked as obsolete in the current code (note the warn("Function %s: obsolete routine kind", name); in the functions that create routine structures). git blame indicates that these were made obsolete in 1998 but I couldn't find any entry in the old ChangeLog, so I'm guessing this happened even before the code was forked as a GNU project.

I also don't think they are going to be used since procedures and functions don't provide error codes during return and we can do everything with simpleroutine and routine, which are superior alternatives.

Note that I've also cross-compiled the Hurd from the sources and these routine kinds are not used anywhere in the defs files.


Flavio
 

> * lexxer.l: Remove tokens.
> * parser.y: Remove token types and production rules.
> * routine.c: Remove rtMakeProcedure, rtMakeSimpleProcedure,
> rtMakeFunction.
> * routine.h: Remove enum values rkSimpleProcedure, rkProcedure,
> rkFunction. Remove dead fields from struct routine.
> * user.c: Simplify and remove dead code.
> ---
>  lexxer.l  |  3 ---
>  parser.y  | 19 --------------
>  routine.c | 85 +++++----------------------------------------------------------
>  routine.h | 22 +++--------------
>  user.c    | 32 ++++++------------------
>  5 files changed, 18 insertions(+), 143 deletions(-)
>
> diff --git a/lexxer.l b/lexxer.l
> index 06b04e2..bd7a718 100644
> --- a/lexxer.l
> +++ b/lexxer.l
> @@ -108,9 +108,6 @@ static void doSharp(const char *body); /* process body of # directives */
>  %%
>
>  <Normal>(?i:routine)         RETURN(syRoutine);
> -<Normal>(?i:function)                RETURN(syFunction);
> -<Normal>(?i:procedure)               RETURN(syProcedure);
> -<Normal>(?i:simpleprocedure) RETURN(sySimpleProcedure);
>  <Normal>(?i:simpleroutine)   RETURN(sySimpleRoutine);
>  <Normal>(?i:subsystem)               RETURN(sySubsystem);
>  <Normal>(?i:msgoption)               RETURN(syMsgOption);
> diff --git a/parser.y b/parser.y
> index e88fd22..b05bcc9 100644
> --- a/parser.y
> +++ b/parser.y
> @@ -27,9 +27,6 @@
>  %token       sySkip
>  %token       syRoutine
>  %token       sySimpleRoutine
> -%token       sySimpleProcedure
> -%token       syProcedure
> -%token       syFunction
>
>  %token       sySubsystem
>  %token       syKernelUser
> @@ -111,7 +108,6 @@
>  %type        <type> BasicTypeSpec PrevTypeSpec ArgumentType
>  %type        <symtype> PrimIPCType IPCType
>  %type        <routine> RoutineDecl Routine SimpleRoutine
> -%type        <routine> Procedure SimpleProcedure Function
>  %type        <direction> Direction
>  %type        <argument> Argument Arguments ArgumentList
>  %type        <flag> IPCFlags
> @@ -582,9 +578,6 @@ IntExp                    :       IntExp  syPlus  IntExp
>
>  RoutineDecl          :       Routine                 { $$ = $1; }
>                       |       SimpleRoutine           { $$ = $1; }
> -                     |       Procedure               { $$ = $1; }
> -                     |       SimpleProcedure         { $$ = $1; }
> -                     |       Function                { $$ = $1; }
>                       ;
>
>  Routine                      :       syRoutine syIdentifier Arguments
> @@ -595,18 +588,6 @@ SimpleRoutine            :       sySimpleRoutine syIdentifier Arguments
>                               { $$ = rtMakeSimpleRoutine($2, $3); }
>                       ;
>
> -Procedure            :       syProcedure syIdentifier Arguments
> -                             { $$ = rtMakeProcedure($2, $3); }
> -                     ;
> -
> -SimpleProcedure              :       sySimpleProcedure syIdentifier Arguments
> -                             { $$ = rtMakeSimpleProcedure($2, $3); }
> -                     ;
> -
> -Function             :       syFunction syIdentifier Arguments ArgumentType
> -                             { $$ = rtMakeFunction($2, $3, $4); }
> -                     ;
> -
>  Arguments            :       syLParen syRParen
>                               { $$ = argNULL; }
>                       |       syLParen ArgumentList syRParen
> diff --git a/routine.c b/routine.c
> index ddf5770..d9154ef 100644
> --- a/routine.c
> +++ b/routine.c
> @@ -59,7 +59,6 @@ rtAlloc(void)
>       fatal("rtAlloc(): %s", unix_error_string(errno));
>      new->rtNumber = rtNumber++;
>      new->rtName = strNULL;
> -    new->rtErrorName = strNULL;
>      new->rtUserName = strNULL;
>      new->rtServerName = strNULL;
>
> @@ -136,54 +135,6 @@ rtMakeSimpleRoutine(identifier_t name, argument_t *args)
>      return rt;
>  }
>
> -routine_t *
> -rtMakeProcedure(identifier_t name, argument_t *args)
> -{
> -    routine_t *rt = rtAlloc();
> -
> -    rt->rtName = name;
> -    rt->rtKind = rkProcedure;
> -    rt->rtArgs = args;
> -
> -    warn("Procedure %s: obsolete routine kind", name);
> -
> -    return rt;
> -}
> -
> -routine_t *
> -rtMakeSimpleProcedure(identifier_t name, argument_t *args)
> -{
> -    routine_t *rt = rtAlloc();
> -
> -    rt->rtName = name;
> -    rt->rtKind = rkSimpleProcedure;
> -    rt->rtArgs = args;
> -
> -    warn("SimpleProcedure %s: obsolete routine kind", name);
> -
> -    return rt;
> -}
> -
> -routine_t *
> -rtMakeFunction(identifier_t name, argument_t *args, ipc_type_t *type)
> -{
> -    routine_t *rt = rtAlloc();
> -    argument_t *ret = argAlloc();
> -
> -    ret->argName = name;
> -    ret->argKind = akReturn;
> -    ret->argType = type;
> -    ret->argNext = args;
> -
> -    rt->rtName = name;
> -    rt->rtKind = rkFunction;
> -    rt->rtArgs = ret;
> -
> -    warn("Function %s: obsolete routine kind", name);
> -
> -    return rt;
> -}
> -
>  const char *
>  rtRoutineKindToStr(routine_kind_t rk)
>  {
> @@ -193,12 +144,6 @@ rtRoutineKindToStr(routine_kind_t rk)
>       return "Routine";
>        case rkSimpleRoutine:
>       return "SimpleRoutine";
> -      case rkProcedure:
> -     return "Procedure";
> -      case rkSimpleProcedure:
> -     return "SimpleProcedure";
> -      case rkFunction:
> -     return "Function";
>        default:
>       fatal("rtRoutineKindToStr(%d): not a routine_kind_t", rk);
>       /*NOTREACHED*/
> @@ -290,12 +235,7 @@ rtPrintRoutine(const routine_t *rt)
>      for (arg = rt->rtArgs; arg != argNULL; arg = arg->argNext)
>       rtPrintArg(arg);
>
> -    if (rt->rtKind == rkFunction)
> -     printf("): %s\n", rt->rtReturn->argType->itName);
> -    else
> -     printf(")\n");
> -
> -    printf("\n");
> +    printf(")\n");
>  }
>
>  /*
> @@ -932,15 +872,10 @@ rtCheckArgTypes(routine_t *rt)
>       error("%s %s doesn't have a server port argument",
>             rtRoutineKindToStr(rt->rtKind), rt->rtName);
>
> -    if ((rt->rtKind == rkFunction) &&
> -     (rt->rtReturn == argNULL))
> -     error("Function %s doesn't have a return arg", rt->rtName);
> +    if (rt->rtReturn != argNULL)
> +     error("routine %s has a return arg", rt->rtName);
>
> -    if ((rt->rtKind != rkFunction) &&
> -     (rt->rtReturn != argNULL))
> -     error("non-function %s has a return arg", rt->rtName);
> -
> -    if ((rt->rtReturn == argNULL) && !rt->rtProcedure)
> +    if (rt->rtReturn == argNULL)
>       rt->rtReturn = rt->rtRetCode;
>
>      rt->rtServerReturn = rt->rtReturn;
> @@ -1250,12 +1185,7 @@ rtCheckRoutine(routine_t *rt)
>  {
>      /* Initialize random fields. */
>
> -    rt->rtErrorName = ErrorProc;
> -    rt->rtOneWay = ((rt->rtKind == rkSimpleProcedure) ||
> -                 (rt->rtKind == rkSimpleRoutine));
> -    rt->rtProcedure = ((rt->rtKind == rkProcedure) ||
> -                    (rt->rtKind == rkSimpleProcedure));
> -    rt->rtUseError = rt->rtProcedure || (rt->rtKind == rkFunction);
> +    rt->rtOneWay = (rt->rtKind == rkSimpleRoutine);
>      rt->rtServerName = strconcat(ServerPrefix, rt->rtName);
>      rt->rtServerName = strconcat(RoutinePrefix, rt->rtServerName);
>      rt->rtUserName = strconcat(UserPrefix, rt->rtName);
> @@ -1342,8 +1272,5 @@ rtCheckRoutine(routine_t *rt)
>      rtCheckDestroy(rt);
>      rtAddByReference(rt);
>
> -    if (rt->rtKind == rkFunction)
> -     rt->rtNoReplyArgs = FALSE;
> -    else
> -     rt->rtNoReplyArgs = !rtCheckMask(rt->rtArgs, akbReturnSnd);
> +    rt->rtNoReplyArgs = !rtCheckMask(rt->rtArgs, akbReturnSnd);
>  }
> diff --git a/routine.h b/routine.h
> index f80a174..2b79b27 100644
> --- a/routine.h
> +++ b/routine.h
> @@ -264,7 +264,6 @@ typedef u_int  arg_kind_t;
>
>  typedef struct argument
>  {
> -    /* if argKind == akReturn, then argName is name of the function */
>      identifier_t argName;
>      struct argument *argNext;
>
> @@ -305,18 +304,14 @@ typedef struct argument
>
>  /*
>   * The various routine kinds' peculiarities are abstracted by rtCheckRoutine
> - * into attributes like rtOneWay, rtProcedure, etc.  These are what
> - * code generation should use.  It is Bad Form for code generation to
> - * test rtKind.
> + * into attributes like rtOneWay, etc.  These are what code generation should
> + * use.  It is bad Form for code generation to test rtKind.
>   */
>
>  typedef enum
>  {
>      rkRoutine,
>      rkSimpleRoutine,
> -    rkSimpleProcedure,
> -    rkProcedure,
> -    rkFunction,
>  } routine_kind_t;
>
>  typedef struct routine
> @@ -329,12 +324,7 @@ typedef struct routine
>      identifier_t rtUserName; /* user-visible name (UserPrefix + Name) */
>      identifier_t rtServerName;       /* server-side name (ServerPrefix + Name) */
>
> -    /* rtErrorName is only used for Procs, SimpleProcs, & Functions */
> -    identifier_t rtErrorName;        /* error-handler name */
> -
> -    boolean_t rtOneWay;              /* SimpleProcedure or SimpleRoutine */
> -    boolean_t rtProcedure;   /* Procedure or SimpleProcedure */
> -    boolean_t rtUseError;    /* Procedure or Function */
> +    boolean_t rtOneWay;              /* TRUE for SimpleRoutine */
>
>      boolean_t rtSimpleFixedRequest;  /* fixed msg-simple value in request */
>      boolean_t rtSimpleSendRequest;   /* in any case, initial value */
> @@ -362,7 +352,7 @@ typedef struct routine
>      argument_t *rtRequestPort;       /* always non-NULL, defaults to first arg */
>      argument_t *rtUReplyPort;        /* always non-NULL, defaults to Mig-supplied */
>      argument_t *rtSReplyPort;        /* always non-NULL, defaults to Mig-supplied */
> -    argument_t *rtReturn;    /* non-NULL unless rtProcedure */
> +    argument_t *rtReturn;    /* non-NULL */
>      argument_t *rtServerReturn;      /* NULL or rtReturn  */
>      argument_t *rtRetCode;   /* always non-NULL */
>      argument_t *rtWaitTime;  /* if non-NULL, will use MACH_RCV_TIMEOUT */
> @@ -388,10 +378,6 @@ extern boolean_t rtCheckMaskFunction(const argument_t *args, u_int mask,
>
>  extern routine_t *rtMakeRoutine(identifier_t name, argument_t *args);
>  extern routine_t *rtMakeSimpleRoutine(identifier_t name, argument_t *args);
> -extern routine_t *rtMakeProcedure(identifier_t name, argument_t *args);
> -extern routine_t *rtMakeSimpleProcedure(identifier_t name, argument_t *args);
> -extern routine_t *rtMakeFunction(identifier_t name, argument_t *args,
> -                              ipc_type_t *type);
>
>  extern void rtPrintRoutine(const routine_t *rt);
>  extern void rtCheckRoutine(routine_t *rt);
> diff --git a/user.c b/user.c
> index 1f3ba3d..66859f0 100644
> --- a/user.c
> +++ b/user.c
> @@ -213,7 +213,7 @@ WriteVarDecls(FILE *file, const routine_t *rt)
>       fprintf(file, "\tReply *OutP = &Mess.Out;\n");
>      fprintf(file, "\n");
>
> -    if (!rt->rtOneWay || rt->rtProcedure)
> +    if (!rt->rtOneWay)
>       fprintf(file, "\tmach_msg_return_t msg_result;\n");
>
>      if (!rt->rtSimpleFixedRequest)
> @@ -252,11 +252,9 @@ WriteVarDecls(FILE *file, const routine_t *rt)
>  static void
>  WriteMsgError(FILE *file, const routine_t *rt, const char *error_msg)
>  {
> -    if (rt->rtProcedure)
> -     fprintf(file, "\t\t{ %s(%s); return; }\n", rt->rtErrorName, error_msg);
> -    else if (rt->rtReturn != rt->rtRetCode)
> +    if (rt->rtReturn != rt->rtRetCode)
>      {
> -     fprintf(file, "\t\t{ %s(%s); ", rt->rtErrorName, error_msg);
> +     fprintf(file, "\t\t{ (%s); ", error_msg);
>       if (rt->rtNumReplyVar > 0)
>           fprintf(file, "OutP = &Mess.Out; ");
>       fprintf(file, "return OutP->%s; }\n", rt->rtReturn->argMsgField);
> @@ -267,16 +265,12 @@ WriteMsgError(FILE *file, const routine_t *rt, const char *error_msg)
>
>  /*************************************************************
>   *   Writes the send call when there is to be no subsequent
> - *   receive. Called by WriteRoutine for SimpleProcedures
> - *   or SimpleRoutines
> + *   receive. Called by WriteRoutine for SimpleRoutines.
>   *************************************************************/
>  static void
>  WriteMsgSend(FILE *file, const routine_t *rt)
>  {
> -    const char *MsgResult = (rt->rtProcedure)
> -                     ? "msg_result ="
> -                     : "return";
> -
> +    const char *MsgResult = "return";
>      char SendSize[24];
>
>      if (rt->rtNumRequestVar == 0)
> @@ -301,12 +295,6 @@ WriteMsgSend(FILE *file, const routine_t *rt)
>               " MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);\n"
>               );
>      }
> -
> -    if (rt->rtProcedure)
> -    {
> -     fprintf(file, "\tif (msg_result != MACH_MSG_SUCCESS)\n");
> -     WriteMsgError(file, rt, "msg_result");
> -    }
>  }
>
>  /*************************************************************
> @@ -342,7 +330,7 @@ WriteMsgCheckReceive(FILE *file, const routine_t *rt, const char *success)
>  /*************************************************************
>   *  Writes the rpc call and the code to check for errors.
>   *  This is the default code to be generated. Called by WriteRoutine
> - *  for all routine types except SimpleProcedure and SimpleRoutine.
> + *  for all routine types except SimpleRoutine.
>   *************************************************************/
>  static void
>  WriteMsgRPC(FILE *file, const routine_t *rt)
> @@ -1213,12 +1201,8 @@ WriteRoutine(FILE *file, const routine_t *rt)
>       else {
>           WriteReplyArgs(file, rt);
>
> -         /* return the return value, if any */
> -
> -         if (rt->rtProcedure)
> -             fprintf(file, "\t/* Procedure - no return needed */\n");
> -         else
> -             WriteReturnValue(file, rt);
> +         /* return the return value */
> +            WriteReturnValue(file, rt);
>       }
>      }
>
> --
> 2.6.4
>
>

--
Samuel
<s> cool, j'ai un rapport a rendre pour le 31 decembre a minuit...
 -+- #ens-mim - bonne année ! -+-



--
Flávio Cruz / flaviocruz@gmail.com

reply via email to

[Prev in Thread] Current Thread [Next in Thread]