obj.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /* $Id$ */
  2. /*
  3. * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
  4. * See the copyright notice in the ACK home directory, in the file "Copyright".
  5. */
  6. #include <local.h>
  7. #include <stdlib.h>
  8. #include <stdio.h>
  9. #include <out.h>
  10. #include <ranlib.h>
  11. #include <arch.h>
  12. #include "object.h"
  13. #if ! defined(CHAR_UNSIGNED)
  14. #define CHAR_UNSIGNED 0
  15. #endif
  16. #if CHAR_UNSIGNED
  17. #define Xchar(ch) (ch)
  18. #else
  19. #define Xchar(ch) ((ch) & 0377)
  20. #endif
  21. #if ! defined(BYTE_ORDER)
  22. #define BYTE_ORDER 0x3210
  23. #endif
  24. #if (BYTE_ORDER == 0x3210 || BYTE_ORDER == 0x1032)
  25. #define uget2(c) (Xchar((c)[0]) | ((unsigned) Xchar((c)[1]) << 8))
  26. #define Xput2(i, c) (((c)[0] = (i)), ((c)[1] = (i) >> 8))
  27. #define put2(i, c) { register int j = (i); Xput2(j, c); }
  28. #else
  29. #define uget2(c) (* ((unsigned short *) (c)))
  30. #define Xput2(i, c) (* ((short *) (c)) = (i))
  31. #define put2(i, c) Xput2(i, c)
  32. #endif
  33. #define get2(c) ((short) uget2(c))
  34. #if BYTE_ORDER != 0x0123
  35. #define get4(c) (uget2(c) | ((long) uget2((c)+2) << 16))
  36. #define put4(l, c) { register long x=(l); \
  37. Xput2((int)x,c); \
  38. Xput2((int)(x>>16),(c)+2); \
  39. }
  40. #else
  41. #define get4(c) (* ((long *) (c)))
  42. #define put4(l, c) (* ((long *) (c)) = (l))
  43. #endif
  44. #define SECTCNT 3 /* number of sections with own output buffer */
  45. #if BIGMACHINE
  46. #define WBUFSIZ (8*BUFSIZ)
  47. #else
  48. #define WBUFSIZ BUFSIZ
  49. #endif
  50. struct fil {
  51. int cnt;
  52. char *pnow;
  53. char *pbegin;
  54. long currpos;
  55. int fd;
  56. char pbuf[WBUFSIZ];
  57. };
  58. extern struct fil __parts[];
  59. #define PARTEMIT 0
  60. #define PARTRELO (PARTEMIT+SECTCNT)
  61. #define PARTNAME (PARTRELO+1)
  62. #define PARTCHAR (PARTNAME+1)
  63. #ifdef SYMDBUG
  64. #define PARTDBUG (PARTCHAR+1)
  65. #else
  66. #define PARTDBUG (PARTCHAR+0)
  67. #endif
  68. #define NPARTS (PARTDBUG + 1)
  69. #define getsect(s) (PARTEMIT+((s)>=(SECTCNT-1)?(SECTCNT-1):(s)))