home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 6 / FreshFish_September1994.bin / bbs / gnu / gcc-2.6.0-src.lha / GNU / src / amiga / gcc-2.6.0 / config / m68k / xm-amigados.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-07-29  |  7.2 KB  |  219 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 "m68k/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.    Phil.B: 29-May-94 quick hack (number 20 added to length) because xgcc
  43.    doesn't work.
  44.  */
  45.  
  46. #define PEXECUTE(SEARCH_FLAG,PROGRAM,ARGV,NOT_LAST) \
  47. ({char *_argline;                        \
  48.   int _arglinelength, _i;                    \
  49.                                 \
  50.   for (_i = 1, _arglinelength=0; ARGV[_i]; ++_i)        \
  51.     _arglinelength += strlen(ARGV[_i]) + 1;            \
  52.                                 \
  53.   _arglinelength += strlen(PROGRAM) + 20 + 1;            \
  54.                                 \
  55.   if (!(_argline = (char *)alloca(_arglinelength)))         \
  56.     pfatal_with_name ("alloca");                \
  57.                                 \
  58.   strcpy(_argline, PROGRAM);                    \
  59.   for (_i = 1; ARGV[_i]; ++_i)                     \
  60.     {                                \
  61.       strcat(_argline, " ");                    \
  62.       strcat(_argline, ARGV[_i]);                \
  63.     }                                \
  64.                                 \
  65.   ssystem(_argline); })                        \
  66.  
  67. #define PEXECUTE_RESULT(STATUS, COMMAND) \
  68.   ({ STATUS = COMMAND.pid; })
  69.  
  70. #else
  71.  
  72. /* the vfork() version. This one has the drawback, that gcc is not 
  73.    interruptible when started from make, since ixemul.library doesn't yet
  74.    propagate ^C to subprocesses. */
  75.  
  76. #define PEXECUTE(SEARCH_FLAG,PROGRAM,ARGV,NOT_LAST) \
  77. ({int (*_func)() = (SEARCH_FLAG ? execv : execvp);            \
  78.   int _pid;                                \
  79.   int _pdes[2];                                \
  80.   int _input_desc = last_pipe_input;                    \
  81.   int _output_desc = STDOUT_FILE_NO;                    \
  82.   int _retries, _sleep_interval, _result;                \
  83.                                     \
  84.   /* If this isn't the last process, make a pipe for its output,    \
  85.      and record it as waiting to be the input to the next process.  */    \
  86.                                     \
  87.   if (NOT_LAST)                                \
  88.     {                                    \
  89.       if (pipe (_pdes) < 0)                        \
  90.     pfatal_with_name ("pipe");                    \
  91.       _output_desc = _pdes[WRITE_PORT];                    \
  92.       last_pipe_input = _pdes[READ_PORT];                \
  93.     }                                    \
  94.   else                                    \
  95.     last_pipe_input = STDIN_FILE_NO;                    \
  96.                                     \
  97.   /* Fork a subprocess; wait and retry if it fails.  */            \
  98.   _sleep_interval = 1;                            \
  99.   for (_retries = 0; _retries < 4; _retries++)                \
  100.     {                                    \
  101.       _pid = vfork ();                            \
  102.       if (_pid >= 0)                            \
  103.     break;                                \
  104.       sleep (_sleep_interval);                        \
  105.       _sleep_interval *= 2;                        \
  106.     }                                    \
  107.                                     \
  108.   switch (_pid)                                \
  109.     {                                    \
  110.     case -1:                                \
  111.       pfatal_with_name ("vfork");                    \
  112.       /* NOTREACHED */                            \
  113.       _result = 0;                            \
  114.       break;                                \
  115.                                     \
  116.     case 0: /* child */                            \
  117.       /* Move the input and output pipes into place, if nec.  */    \
  118.       if (_input_desc != STDIN_FILE_NO)                    \
  119.     {                                \
  120.       close (STDIN_FILE_NO);                    \
  121.       dup (_input_desc);                        \
  122.       close (_input_desc);                        \
  123.     }                                \
  124.       if (_output_desc != STDOUT_FILE_NO)                \
  125.     {                                \
  126.       close (STDOUT_FILE_NO);                    \
  127.       dup (_output_desc);                        \
  128.       close (_output_desc);                        \
  129.     }                                \
  130.                                     \
  131.       /* Close the parent's descs that aren't wanted here.  */        \
  132.       if (last_pipe_input != STDIN_FILE_NO)                \
  133.     close (last_pipe_input);                    \
  134.                                     \
  135.       /* Exec the program.  */                        \
  136.       (*_func) (PROGRAM, ARGV);                        \
  137.       perror_exec (PROGRAM);                        \
  138.       exit (-1);                            \
  139.       /* NOTREACHED */                            \
  140.       _result = 0;                            \
  141.       break;                                \
  142.                                     \
  143.     default:                                \
  144.       /* In the parent, after forking.                    \
  145.      Close the descriptors that we made for this child.  */        \
  146.       if (_input_desc != STDIN_FILE_NO)                    \
  147.     close (_input_desc);                        \
  148.       if (_output_desc != STDOUT_FILE_NO)                \
  149.     close (_output_desc);                        \
  150.                                     \
  151.       /* Return child's process number.  */                \
  152.       _result = _pid;                            \
  153.       break;                                \
  154.     }                                     \
  155. _result; })                                \
  156.  
  157. #define PEXECUTE_RESULT(STATUS, COMMAND) \
  158.   ({ wait (& STATUS); })
  159.  
  160. #endif /* AMIGADOS_FORK_GCC */
  161.  
  162. /* the following macros are stolen more or less from xm-vms.h ... */
  163.  
  164. /* This macro is used to help compare filenames in cp-lex.c.
  165.  
  166.    We also need to make sure that the names are all lower case, because
  167.    we must be able to compare filenames to determine if a file implements
  168.    a class.  */
  169.  
  170. #define FILE_NAME_NONDIRECTORY(C)                \
  171. ({                                \
  172.    extern char *rindex();                    \
  173.    char * pnt_ = (C), * pnt1_;                    \
  174.    pnt1_ = pnt_ - 1;                        \
  175.    while (*++pnt1_)                        \
  176.      if ((*pnt1_ >= 'A' && *pnt1_ <= 'Z')) *pnt1_ |= 0x20;    \
  177.    pnt1_ = rindex (pnt_, '/');                     \
  178.    pnt1_ = (pnt1_ == 0 ? rindex (pnt_, ':') : pnt1_);        \
  179.    (pnt1_ == 0 ? pnt_ : pnt1_ + 1);                \
  180.  })
  181.  
  182. /* Macro to generate the name of the cross reference file.  The standard
  183.    one does not work, since it was written assuming that the conventions
  184.    of a unix style filesystem will work on the host system.
  185.  
  186.    Contrary to VMS, I'm using the original unix filename, there's no reason
  187.    not to use this under AmigaDOS. */
  188.  
  189. #define XREF_FILE_NAME(BUFF, NAME)    \
  190.   s = FILE_NAME_NONDIRECTORY (NAME);            \
  191.   if (s == NAME) sprintf(BUFF, ".%s.gxref", NAME);    \
  192.   else {                        \
  193.     unsigned char ch = *s; /* could be Latin1 char.. */    \
  194.     /* temporary: cut the filename from the directory */\
  195.     *s = 0;                        \
  196.     sprintf (BUFF, "%s.%c%s.gxref", NAME, ch, s+1);    \
  197.     /* and restore the filename */            \
  198.     *s = ch;                        \
  199.   }                            \
  200.  
  201. /* Macro that is used in cp-xref.c to determine whether a file name is
  202.    absolute or not.
  203.  
  204.    This checks for both, '/' as first character, since we're running under
  205.    ixemul.library which provides for this unix'ism, and for the usual 
  206.    logical-terminator, ':', somewhere in the filename. */
  207.  
  208. #define FILE_NAME_ABSOLUTE_P(NAME) (NAME[0] == '/' || index(NAME, ':'))
  209.  
  210. /* the colon conflicts with the name space of logicals */
  211.  
  212. #define PATH_SEPARATOR ','
  213.  
  214. /* AmigaDOS handles rename(2) *much* better than any link(2)/unlink(2)
  215.    hacks. It's actually the inverse case as on Unix. rename(2) was always
  216.    there, link(2) is new with OS 2.0 */
  217.  
  218. #define HAVE_rename 1
  219.