Print this page
make: unifdef SUN5_0 (defined)

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/make/lib/mksh/misc.cc
          +++ new/usr/src/cmd/make/lib/mksh/misc.cc
↓ open down ↓ 41 lines elided ↑ open up ↑
  42   42   */
  43   43  #include <bsd/bsd.h>            /* bsd_signal() */
  44   44  #include <mksh/i18n.h>          /* get_char_semantics_value() */
  45   45  #include <mksh/misc.h>
  46   46  #include <mksdmsi18n/mksdmsi18n.h>
  47   47  #include <stdarg.h>             /* va_list, va_start(), va_end() */
  48   48  #include <stdlib.h>             /* mbstowcs() */
  49   49  #include <sys/signal.h>         /* SIG_DFL */
  50   50  #include <sys/wait.h>           /* wait() */
  51   51  
  52      -#ifdef SUN5_0
  53   52  #include <string.h>             /* strerror() */
  54      -#endif
  55   53  
  56   54  #if defined (HP_UX) || defined (linux)
  57   55  #include <unistd.h>
  58   56  #endif
  59   57  
  60   58  /*
  61   59   * Defined macros
  62   60   */
  63   61  
  64   62  /*
  65   63   * typedefs & structs
  66   64   */
  67   65  
  68   66  /*
  69   67   * Static variables
  70   68   */
  71      -#ifdef SUN5_0
  72   69  extern "C" {
  73   70          void            (*sigivalue)(int) = SIG_DFL;
  74   71          void            (*sigqvalue)(int) = SIG_DFL;
  75   72          void            (*sigtvalue)(int) = SIG_DFL;
  76   73          void            (*sighvalue)(int) = SIG_DFL;
  77   74  }
  78      -#else
  79      -static  void            (*sigivalue)(int) = (void (*) (int)) SIG_DFL;
  80      -static  void            (*sigqvalue)(int) = (void (*) (int)) SIG_DFL;
  81      -static  void            (*sigtvalue)(int) = (void (*) (int)) SIG_DFL;
  82      -static  void            (*sighvalue)(int) = (void (*) (int)) SIG_DFL;
  83      -#endif
  84   75  
  85   76  long    getname_bytes_count = 0;
  86   77  long    getname_names_count = 0;
  87   78  long    getname_struct_count = 0;
  88   79  
  89   80  long    freename_bytes_count = 0;
  90   81  long    freename_names_count = 0;
  91   82  long    freename_struct_count = 0;
  92   83  
  93   84  long    expandstring_count = 0;
↓ open down ↓ 21 lines elided ↑ open up ↑
 115  106   */
 116  107  char *
 117  108  getmem(register int size)
 118  109  {
 119  110          register char          *result = (char *) malloc((unsigned) size);
 120  111          if (result == NULL) {
 121  112                  char buf[FATAL_ERROR_MSG_SIZE];
 122  113                  sprintf(buf, NOCATGETS("*** Error: malloc(%d) failed: %s\n"), size, strerror(errno));
 123  114                  strcat(buf, catgets(libmksdmsi18n_catd, 1, 126, "mksh: Fatal error: Out of memory\n"));
 124  115                  fputs(buf, stderr);
 125      -#ifdef SUN5_0
 126  116                  exit_status = 1;
 127      -#endif
 128  117                  exit(1);
 129  118          }
 130  119          return result;
 131  120  }
 132  121  
 133  122  /*
 134  123   *      retmem(p)
 135  124   *
 136  125   *      Cover funtion for free() to make it possible to insert advises.
 137  126   *
↓ open down ↓ 139 lines elided ↑ open up ↑
 277  266   *
 278  267   *      Static variables used:
 279  268   *              sigivalue       The original signal handler
 280  269   *              sigqvalue       The original signal handler
 281  270   *              sigtvalue       The original signal handler
 282  271   *              sighvalue       The original signal handler
 283  272   */
 284  273  void
 285  274  enable_interrupt(register void (*handler) (int))
 286  275  {
 287      -#ifdef SUN5_0
 288  276          if (sigivalue != SIG_IGN) {
 289      -#else
 290      -        if (sigivalue != (void (*) (int)) SIG_IGN) {
 291      -#endif
 292  277                  (void) bsd_signal(SIGINT, (SIG_PF) handler);
 293  278          }
 294      -#ifdef SUN5_0
 295  279          if (sigqvalue != SIG_IGN) {
 296      -#else
 297      -        if (sigqvalue != (void (*) (int)) SIG_IGN) {
 298      -#endif
 299  280                  (void) bsd_signal(SIGQUIT, (SIG_PF) handler);
 300  281          }
 301      -#ifdef SUN5_0
 302  282          if (sigtvalue != SIG_IGN) {
 303      -#else
 304      -        if (sigtvalue != (void (*) (int)) SIG_IGN) {
 305      -#endif
 306  283                  (void) bsd_signal(SIGTERM, (SIG_PF) handler);
 307  284          }
 308      -#ifdef SUN5_0
 309  285          if (sighvalue != SIG_IGN) {
 310      -#else
 311      -        if (sighvalue != (void (*) (int)) SIG_IGN) {
 312      -#endif
 313  286                  (void) bsd_signal(SIGHUP, (SIG_PF) handler);
 314  287          }
 315  288  }
 316  289  
 317  290  /*
 318  291   *      setup_char_semantics()
 319  292   *
 320  293   *      Load the vector char_semantics[] with lexical markers
 321  294   *
 322  295   *      Parameters:
↓ open down ↓ 64 lines elided ↑ open up ↑
 387  360          char                    *errbuf;
 388  361  
 389  362          if ((errnum < 0) || (errnum > sys_nerr)) {
 390  363                  errbuf = getmem(6+1+11+1);
 391  364                  (void) sprintf(errbuf, catgets(libmksdmsi18n_catd, 1, 127, "Error %d"), errnum);
 392  365                  return errbuf;
 393  366          } else {
 394  367  #ifdef SUN4_x
 395  368                  return(sys_errlist[errnum]);
 396  369  #endif
 397      -#ifdef SUN5_0
 398  370                  return strerror(errnum);
 399      -#endif
 400  371  
 401  372          }
 402  373  #endif // linux
 403  374  }
 404  375  
 405  376  static char static_buf[MAXPATHLEN*3];
 406  377  
 407  378  /*
 408  379   *      fatal_mksh(format, args...)
 409  380   *
↓ open down ↓ 38 lines elided ↑ open up ↑
 448  419          if (1) {
 449  420                  (void) strcat(buf, cur_wrk_dir);
 450  421                  (void) strcat(buf, get_current_path_mksh());
 451  422                  (void) strcat(buf, "\n");
 452  423          }
 453  424          (void) fputs(buf, stderr);
 454  425          (void) fflush(stderr);
 455  426          if (buf != static_buf) {
 456  427                  retmem_mb(buf);
 457  428          }
 458      -#ifdef SUN5_0
 459  429          exit_status = 1;
 460      -#endif
 461  430          exit(1);
 462  431  }
 463  432  
 464  433  /*
 465  434   *      fatal_reader_mksh(format, args...)
 466  435   *
 467  436   *      Parameters:
 468  437   *              format          printf style format string
 469  438   *              args            arguments to match the format
 470  439   */
↓ open down ↓ 41 lines elided ↑ open up ↑
 512  481  
 513  482  /*
 514  483          if (report_pwd) {
 515  484   */
 516  485          if (1) {
 517  486                  (void) fprintf(stderr,
 518  487                                 catgets(libmksdmsi18n_catd, 1, 133, "Current working directory %s\n"),
 519  488                                 get_current_path_mksh());
 520  489          }
 521  490          (void) fflush(stderr);
 522      -#ifdef SUN5_0
 523  491          exit_status = 1;
 524      -#endif
 525  492          exit(1);
 526  493  }
 527  494  
 528  495  /*
 529  496   *      warning_mksh(format, args...)
 530  497   *
 531  498   *      Print a message and continue.
 532  499   *
 533  500   *      Parameters:
 534  501   *              format          printf type format string
↓ open down ↓ 31 lines elided ↑ open up ↑
 566  533   *
 567  534   *      Global variables used:
 568  535   */
 569  536  char *
 570  537  get_current_path_mksh(void)
 571  538  {
 572  539          char                    pwd[(MAXPATHLEN * MB_LEN_MAX)];
 573  540          static char             *current_path;
 574  541  
 575  542          if (current_path == NULL) {
 576      -#if defined(SUN5_0) || defined(HP_UX) || defined(linux)
 577  543                  getcwd(pwd, sizeof(pwd));
 578      -#else
 579      -                (void) getwd(pwd);
 580      -#endif
 581  544                  if (pwd[0] == (int) nul_char) {
 582  545                          pwd[0] = (int) slash_char;
 583  546                          pwd[1] = (int) nul_char;
 584  547                  }
 585  548                  current_path = strdup(pwd);
 586  549          }
 587  550          return current_path;
 588  551  }
 589  552  
 590  553  /*
↓ open down ↓ 268 lines elided ↑ open up ↑
 859  822   */
 860  823  void
 861  824  handle_interrupt_mksh(int)
 862  825  {
 863  826          (void) fflush(stdout);
 864  827          /* Make sure the processes running under us terminate first. */
 865  828          if (childPid > 0) {
 866  829                  kill(childPid, SIGTERM);
 867  830                  childPid = -1;
 868  831          }
 869      -#if defined(SUN5_0) || defined(HP_UX) || defined(linux)
 870  832          while (wait((int *) NULL) != -1);
 871      -#if defined(SUN5_0)
 872  833          exit_status = 2;
 873      -#endif
 874      -#else
 875      -        while (wait((union wait *) NULL) != -1);
 876      -#endif
 877  834          exit(2);
 878  835  }
 879  836  
 880  837  /*
 881  838   *      setup_interrupt()
 882  839   *
 883  840   *      This routine saves the original interrupt handler pointers
 884  841   *
 885  842   *      Parameters:
 886  843   *
 887  844   *      Static variables used:
 888  845   *              sigivalue       The original signal handler
 889  846   *              sigqvalue       The original signal handler
 890  847   *              sigtvalue       The original signal handler
 891  848   *              sighvalue       The original signal handler
 892  849   */
 893  850  void
 894  851  setup_interrupt(register void (*handler) (int))
 895  852  {
 896      -#ifdef SUN5_0
 897  853          sigivalue = bsd_signal(SIGINT, SIG_IGN);
 898  854          sigqvalue = bsd_signal(SIGQUIT, SIG_IGN);
 899  855          sigtvalue = bsd_signal(SIGTERM, SIG_IGN);
 900  856          sighvalue = bsd_signal(SIGHUP, SIG_IGN);
 901      -#else
 902      -        sigivalue = (void (*) (int)) bsd_signal(SIGINT, SIG_IGN);
 903      -        sigqvalue = (void (*) (int)) bsd_signal(SIGQUIT, SIG_IGN);
 904      -        sigtvalue = (void (*) (int)) bsd_signal(SIGTERM, SIG_IGN);
 905      -        sighvalue = (void (*) (int)) bsd_signal(SIGHUP, SIG_IGN);
 906      -#endif
 907  857          enable_interrupt(handler);
 908  858  }
 909  859  
 910  860  
 911  861  void
 912  862  mbstowcs_with_check(wchar_t *pwcs, const char *s, size_t n)
 913  863  {
 914  864          if(mbstowcs(pwcs, s, n) == -1) {
 915  865                  fatal_mksh(catgets(libmksdmsi18n_catd, 1, 143, "The string `%s' is not valid in current locale"), s);
 916  866          }
↓ open down ↓ 260 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX