home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 7 / FreshFishVol7.bin / bbs / gnu / gcc-2.3.3-src.lha / GNU / src / amiga / gcc-2.3.3 / config / xm-amigados.h < prev    next >
C/C++ Source or Header  |  1994-02-06  |  7KB  |  216 lines

  1. /* Configuration for GNU C-compiler for Commodore Amiga, running AmigaDOS.
  2.    Copyright (C) 1992 Free Software Foundation, Inc.
  3.    Contributed by Markus M. Wild (wild@amiga.physik.unizh.ch).
  4.  
  5. This file is part of GNU CC.
  6.  
  7. GNU CC is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2, or (at your option)
  10. any later version.
  11.  
  12. GNU CC is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. GNU General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with GNU CC; see the file COPYING.  If not, write to
  19. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  20.  
  21. /* first include the generic header, then modify some parts.. */
  22.  
  23. #include "xm-m68k.h"
  24.  
  25. /* Amiga specific headers, such as from the Native Developer Update kits,
  26.    go in SYSTEM_INCLUDE_DIR.  STANDARD_INCLUDE_DIR is the equivalent of
  27.    Unix "/usr/include".  All other include paths are set in Makefile. */
  28.  
  29. #define SYSTEM_INCLUDE_DIR    "/gnu/os-include"
  30. #define STANDARD_INCLUDE_DIR    "/gnu/include"
  31.  
  32. /* Fork one piped subcommand.  SEARCH_FLAG is the system call to use
  33.    (either execv or execvp).  ARGV is the arg vector to use.
  34.    NOT_LAST is nonzero if this is not the last subcommand
  35.    (i.e. its output should be piped to the next one.)  */
  36.  
  37. #ifndef AMIGADOS_FORK_GCC
  38.  
  39. /* This version uses a more or less amigados-conformant way of running a
  40.    program (in the context of the parent). If you want to use -pipe however,
  41.    you'll have to use the vfork() version afterwards. */
  42.  
  43. #define PEXECUTE(SEARCH_FLAG,PROGRAM,ARGV,NOT_LAST) \
  44. ({char *_argline;                        \
  45.   int _arglinelength, _i;                    \
  46.                                 \
  47.   for (_i = 1, _arglinelength=0; ARGV[_i]; ++_i)        \
  48.     _arglinelength += strlen(ARGV[_i]) + 1;            \
  49.                                 \
  50.   _arglinelength += strlen(PROGRAM) + 1;            \
  51.                                 \
  52.   if (!(_argline = (char *)alloca(_arglinelength)))         \
  53.     pfatal_with_name ("alloca");                \
  54.                                 \
  55.   strcpy(_argline, PROGRAM);                    \
  56.   for (_i = 1; ARGV[_i]; ++_i)                     \
  57.     {                                \
  58.       strcat(_argline, " ");                    \
  59.       strcat(_argline, ARGV[_i]);                \
  60.     }                                \
  61.                                 \
  62.   ssystem(_argline); })                        \
  63.  
  64. #define PEXECUTE_RESULT(STATUS, COMMAND) \
  65.   ({ STATUS = COMMAND.pid; })
  66.  
  67. #else
  68.  
  69. /* the vfork() version. This one has the drawback, that gcc is not 
  70.    interruptible when started from make, since ixemul.library doesn't yet
  71.    propagate ^C to subprocesses. */
  72.  
  73. #define PEXECUTE(SEARCH_FLAG,PROGRAM,ARGV,NOT_LAST) \
  74. ({int (*_func)() = (SEARCH_FLAG ? execv : execvp);            \
  75.   int _pid;                                \
  76.   int _pdes[2];                                \
  77.   int _input_desc = last_pipe_input;                    \
  78.   int _output_desc = STDOUT_FILE_NO;                    \
  79.   int _retries, _sleep_interval, _result;                \
  80.                                     \
  81.   /* If this isn't the last process, make a pipe for its output,    \
  82.      and record it as waiting to be the input to the next process.  */    \
  83.                                     \
  84.   if (NOT_LAST)                                \
  85.     {                                    \
  86.       if (pipe (_pdes) < 0)                        \
  87.     pfatal_with_name ("pipe");                    \
  88.       _output_desc = _pdes[WRITE_PORT];                    \
  89.       last_pipe_input = _pdes[READ_PORT];                \
  90.     }                                    \
  91.   else                                    \
  92.     last_pipe_input = STDIN_FILE_NO;                    \
  93.                                     \
  94.   /* Fork a subprocess; wait and retry if it fails.  */            \
  95.   _sleep_interval = 1;                            \
  96.   for (_retries = 0; _retries < 4; _retries++)                \
  97.     {                                    \
  98.       _pid = vfork ();                            \
  99.       if (_pid >= 0)                            \
  100.     break;                                \
  101.       sleep (_sleep_interval);                        \
  102.       _sleep_interval *= 2;                        \
  103.     }                                    \
  104.                                     \
  105.   switch (_pid)                                \
  106.     {                                    \
  107.     case -1:                                \
  108.       pfatal_with_name ("vfork");                    \
  109.       /* NOTREACHED */                            \
  110.       _result = 0;                            \
  111.       break;                                \
  112.                                     \
  113.     case 0: /* child */                            \
  114.       /* Move the input and output pipes into place, if nec.  */    \
  115.       if (_input_desc != STDIN_FILE_NO)                    \
  116.     {                                \
  117.       close (STDIN_FILE_NO);                    \
  118.       dup (_input_desc);                        \
  119.       close (_input_desc);                        \
  120.     }                                \
  121.       if (_output_desc != STDOUT_FILE_NO)                \
  122.     {                                \
  123.       close (STDOUT_FILE_NO);                    \
  124.       dup (_output_desc);                        \
  125.       close (_output_desc);                        \
  126.     }                                \
  127.                                     \
  128.       /* Close the parent's descs that aren't wanted here.  */        \
  129.       if (last_pipe_input != STDIN_FILE_NO)                \
  130.     close (last_pipe_input);                    \
  131.                                     \
  132.       /* Exec the program.  */                        \
  133.       (*_func) (PROGRAM, ARGV);                        \
  134.       perror_exec (PROGRAM);                        \
  135.       exit (-1);                            \
  136.       /* NOTREACHED */                            \
  137.       _result = 0;                            \
  138.       break;                                \
  139.                                     \
  140.     default:                                \
  141.       /* In the parent, after forking.                    \
  142.      Close the descriptors that we made for this child.  */        \
  143.       if (_input_desc != STDIN_FILE_NO)                    \
  144.     close (_input_desc);                        \
  145.       if (_output_desc != STDOUT_FILE_NO)                \
  146.     close (_output_desc);                        \
  147.                                     \
  148.       /* Return child's process number.  */                \
  149.       _result = _pid;                            \
  150.       break;                                \
  151.     }                                     \
  152. _result; })                                \
  153.  
  154. #define PEXECUTE_RESULT(STATUS, COMMAND) \
  155.   ({ wait (& STATUS); })
  156.  
  157. #endif /* AMIGADOS_FORK_GCC */
  158.  
  159. /* the following macros are stolen more or less from xm-vms.h ... */
  160.  
  161. /* This macro is used to help compare filenames in cp-lex.c.
  162.  
  163.    We also need to make sure that the names are all lower case, because
  164.    we must be able to compare filenames to determine if a file implements
  165.    a class.  */
  166.  
  167. #define FILE_NAME_NONDIRECTORY(C)                \
  168. ({                                \
  169.    extern char *rindex();                    \
  170.    char * pnt_ = (C), * pnt1_;                    \
  171.    pnt1_ = pnt_ - 1;                        \
  172.    while (*++pnt1_)                        \
  173.      if ((*pnt1_ >= 'A' && *pnt1_ <= 'Z')) *pnt1_ |= 0x20;    \
  174.    pnt1_ = rindex (pnt_, '/');                     \
  175.    pnt1_ = (pnt1_ == 0 ? rindex (pnt_, ':') : pnt1_);        \
  176.    (pnt1_ == 0 ? pnt_ : pnt1_ + 1);                \
  177.  })
  178.  
  179. /* Macro to generate the name of the cross reference file.  The standard
  180.    one does not work, since it was written assuming that the conventions
  181.    of a unix style filesystem will work on the host system.
  182.  
  183.    Contrary to VMS, I'm using the original unix filename, there's no reason
  184.    not to use this under AmigaDOS. */
  185.  
  186. #define XREF_FILE_NAME(BUFF, NAME)    \
  187.   s = FILE_NAME_NONDIRECTORY (NAME);            \
  188.   if (s == NAME) sprintf(BUFF, ".%s.gxref", NAME);    \
  189.   else {                        \
  190.     unsigned char ch = *s; /* could be Latin1 char.. */    \
  191.     /* temporary: cut the filename from the directory */\
  192.     *s = 0;                        \
  193.     sprintf (BUFF, "%s.%c%s.gxref", NAME, ch, s+1);    \
  194.     /* and restore the filename */            \
  195.     *s = ch;                        \
  196.   }                            \
  197.  
  198. /* Macro that is used in cp-xref.c to determine whether a file name is
  199.    absolute or not.
  200.  
  201.    This checks for both, '/' as first character, since we're running under
  202.    ixemul.library which provides for this unix'ism, and for the usual 
  203.    logical-terminator, ':', somewhere in the filename. */
  204.  
  205. #define FILE_NAME_ABSOLUTE_P(NAME) (NAME[0] == '/' || index(NAME, ':'))
  206.  
  207. /* the colon conflicts with the name space of logicals */
  208.  
  209. #define PATH_SEPARATOR ','
  210.  
  211. /* AmigaDOS handles rename(2) *much* better than any link(2)/unlink(2)
  212.    hacks. It's actually the inverse case as on Unix. rename(2) was always
  213.    there, link(2) is new with OS 2.0 */
  214.  
  215. #define HAVE_rename 1
  216.