home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 200-299 / ff225.lzh / AmigaTCP / src / machdep.h < prev    next >
C/C++ Source or Header  |  1989-06-24  |  2KB  |  97 lines

  1. /* This file defines certain low level operations and characteristics that
  2.  * are likely to be machine dependent.
  3.  */
  4.  
  5. #if    (MPU8086 || MPU8080 || vax)
  6. #define    LITTLE_ENDIAN    /* Low order bytes are first in memory */
  7. #endif
  8.  
  9. #ifdef    AMIGA
  10.  
  11. #ifdef    AMIGADEVDRV
  12. #define    disable()    Forbid()    /* doesn't really return a value */
  13. #define    restore(intst)    Permit()
  14.  
  15. #else
  16.  
  17. #define    disable()    (0)    /* got to return a value */
  18. #define    restore(intst)        /* but we're not gonna do anything */
  19. #endif
  20.  
  21. #ifdef WINDOWIO
  22. #ifdef    putchar
  23. #undef    putchar
  24. #endif
  25. #ifdef    fflush
  26. #undef    fflush
  27. #endif
  28. #define    putchar(c)    amigaputchar(c)
  29. #ifdef LATTICE
  30. #define    fflush(fp)    ((fp)==stdout ? amigaflush() : _flsbf(-1, fp))
  31. #else
  32. #define    fflush(fp)    ((fp)==stdout ? amigaflush() : flsh_(fp, -1))
  33. #endif
  34.                 /* this has to be the same as in stdio.h */
  35. #ifdef LATTICE
  36. #define index strchr
  37. #endif
  38. #endif
  39. #ifdef LATTICE
  40. #undef printf
  41. #endif
  42. #endif WINDOWIO
  43. /* These two lines assume that your compiler's longs are 32 bits and
  44.  * shorts are 16 bits. It is already assumed that chars are 8 bits,
  45.  * but it doesn't matter if they're signed or unsigned.
  46.  */
  47. typedef long int32;        /* 32-bit signed integer */
  48. typedef unsigned short int16;    /* 16-bit unsigned integer */
  49.  
  50. #define    bcopy(a,b,cnt)    movmem(a,b,cnt)
  51.  
  52. #ifdef    LITTLE_ENDIAN
  53. int32 ntohl();
  54. int16 ntohs();
  55. #else    /* Degenerate case for Big Endian machines */
  56. #define    ntohl(x)    (x)
  57. #define ntohs(x)    (x)
  58. #endif
  59.  
  60. #define    min(x,y)    ((x)<(y)?(x):(y))
  61. #define    max(x,y)    ((x)>(y)?(x):(y))
  62.  
  63. int16 cksum();
  64.  
  65. /* Host-to-network and network-to-host are symmetrical */
  66. #define htonl(x)    ntohl(x)
  67. #define    htons(x)    ntohs(x)
  68.  
  69. #ifdef    MPU8080    /* Assembler routines are available */
  70. int16 hinibble(),lonibble(),hibyte(),lobyte(),hiword(),loword();
  71.  
  72. #else
  73.  
  74. /* Extract a short from a long */
  75. #define    hiword(x)    ((int16)((x) >> 16))
  76. #define    loword(x)    ((int16)(x))
  77.  
  78. /* Extract a byte from a short */
  79. #define    hibyte(x)    (((x) >> 8) & 0xff)
  80. #define    lobyte(x)    ((x) & 0xff)
  81.  
  82. /* Extract nibbles from a byte */
  83. #define    hinibble(x)    (((x) >> 4) & 0xf)
  84. #define    lonibble(x)    ((x) & 0xf)
  85.  
  86. #endif
  87.  
  88. /* Define null object pointer in case stdio.h isn't included */
  89. #ifndef    NULL
  90. /* General purpose NULL pointer */
  91. #define    NULL (void *)0
  92. #endif
  93. #define    NULLCHAR (char *)NULL    /* Null character pointer */
  94. #define    NULLFP     (int (*)())0    /* Null pointer to function returning int */
  95. #define    NULLVFP     (void (*)())0    /* Null pointer to function returning void */
  96. #define    NULLFILE (FILE *)NULL    /* Null file pointer */
  97.