home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.2 (Developer) / NS_dev_3.2.iso / NextDeveloper / Source / GNU / cctools / include / stuff / bytesex.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-04  |  4.6 KB  |  172 lines

  1. /* bytesex.h */
  2. #import <mach-o/fat.h>
  3. #import <mach-o/loader.h>
  4. #import <mach/m68k/thread_status.h>
  5. #import <mach/m98k/thread_status.h>
  6. #import <mach/m88k/thread_status.h>
  7. #import <mach/i860/thread_status.h>
  8. #import <mach/i386/thread_status.h>
  9. #import <mach-o/nlist.h>
  10. #import <mach-o/reloc.h>
  11. #import <bsd/ranlib.h>
  12. #import "stuff/bool.h"
  13.  
  14. enum byte_sex {
  15.     UNKNOWN_BYTE_SEX,
  16.     BIG_ENDIAN_BYTE_SEX,
  17.     LITTLE_ENDIAN_BYTE_SEX
  18. };
  19.  
  20. #define SWAP_SHORT(a) ( ((a & 0xff) << 8) | ((unsigned short)(a) >> 8) )
  21.  
  22. #define SWAP_LONG(a) ( ((a) << 24) | \
  23.               (((a) << 8) & 0x00ff0000) | \
  24.               (((a) >> 8) & 0x0000ff00) | \
  25.     ((unsigned long)(a) >> 24) )
  26.  
  27. extern float SWAP_FLOAT(
  28.     float f);
  29.  
  30. extern double SWAP_DOUBLE(
  31.     double d);
  32.  
  33. extern enum byte_sex get_host_byte_sex(
  34.     void);
  35.  
  36. extern void swap_fat_header(
  37.     struct fat_header *fat_header,
  38.     enum byte_sex target_byte_sex);
  39.  
  40. extern void swap_fat_arch(
  41.     struct fat_arch *fat_archs,
  42.     unsigned long nfat_arch,
  43.     enum byte_sex target_byte_sex);
  44.  
  45. extern void swap_mach_header(
  46.     struct mach_header *mh,
  47.     enum byte_sex target_byte_sex);
  48.  
  49. extern void swap_load_command(
  50.     struct load_command *lc,
  51.     enum byte_sex target_byte_sex);
  52.  
  53. extern void swap_segment_command(
  54.     struct segment_command *sg,
  55.     enum byte_sex target_byte_sex);
  56.  
  57. extern void swap_section(
  58.     struct section *s,
  59.     unsigned long nsects,
  60.     enum byte_sex target_byte_sex);
  61.  
  62. extern void swap_symtab_command(
  63.     struct symtab_command *st,
  64.     enum byte_sex target_byte_sex);
  65.  
  66. extern void swap_symseg_command(
  67.     struct symseg_command *ss,
  68.     enum byte_sex target_byte_sex);
  69.  
  70. extern void swap_fvmlib_command(
  71.     struct fvmlib_command *fl,
  72.     enum byte_sex target_byte_sex);
  73.  
  74. extern void swap_fvmfile_command(
  75.     struct fvmfile_command *ff,
  76.     enum byte_sex target_byte_sex);
  77.  
  78. extern void swap_thread_command(
  79.     struct thread_command *ut,
  80.     enum byte_sex target_byte_sex);
  81.  
  82. extern void swap_m68k_thread_state_regs(
  83.     struct m68k_thread_state_regs *cpu,
  84.     enum byte_sex target_byte_sex);
  85.  
  86. extern void swap_m68k_thread_state_68882(
  87.     struct m68k_thread_state_68882 *fpu,
  88.     enum byte_sex target_byte_sex);
  89.  
  90. extern void swap_m68k_thread_state_user_reg(
  91.     struct m68k_thread_state_user_reg *user_reg,
  92.     enum byte_sex target_byte_sex);
  93.  
  94. extern void swap_m98k_thread_state_grf_t(
  95.     m98k_thread_state_grf_t *cpu,
  96.     enum byte_sex target_byte_sex);
  97.  
  98. extern void swap_m88k_thread_state_grf_t(
  99.     m88k_thread_state_grf_t *cpu,
  100.     enum byte_sex target_byte_sex);
  101.  
  102. extern void swap_m88k_thread_state_xrf_t(
  103.     m88k_thread_state_xrf_t *fpu,
  104.     enum byte_sex target_byte_sex);
  105.  
  106. extern void swap_m88k_thread_state_user_t(
  107.     m88k_thread_state_user_t *user,
  108.     enum byte_sex target_byte_sex);
  109.  
  110. extern void swap_m88110_thread_state_impl_t(
  111.     m88110_thread_state_impl_t *spu,
  112.     enum byte_sex target_byte_sex);
  113.  
  114. extern void swap_i860_thread_state_regs(
  115.     struct i860_thread_state_regs *cpu,
  116.     enum byte_sex target_byte_sex);
  117.  
  118. extern void swap_i386_thread_state(
  119.     i386_thread_state_t *cpu,
  120.     enum byte_sex target_byte_sex);
  121.  
  122. extern void swap_i386_thread_fpstate(
  123.     i386_thread_fpstate_t *fpu,
  124.     enum byte_sex target_byte_sex);
  125.  
  126. extern void swap_i386_thread_exceptstate(
  127.     i386_thread_exceptstate_t *exc,
  128.     enum byte_sex target_byte_sex);
  129.  
  130. extern void swap_i386_thread_cthreadstate(
  131.     i386_thread_cthreadstate_t *user,
  132.     enum byte_sex target_byte_sex);
  133.  
  134. extern void swap_ident_command(
  135.     struct ident_command *id,
  136.     enum byte_sex target_byte_sex);
  137.  
  138. extern void swap_nlist(
  139.     struct nlist *symbols,
  140.     unsigned long nsymbols,
  141.     enum byte_sex target_byte_sex);
  142.  
  143. extern void swap_ranlib(
  144.     struct ranlib *ranlibs,
  145.     unsigned long nranlibs,
  146.     enum byte_sex target_byte_sex);
  147.  
  148. extern void swap_relocation_info(
  149.     struct relocation_info *relocs,
  150.     unsigned long nrelocs,
  151.     enum byte_sex target_byte_sex);
  152.  
  153. /*
  154.  * swap_object_headers() swaps the object file headers from the host byte sex
  155.  * into the non-host byte sex.  It returns TRUE if it can and did swap the
  156.  * headers else returns FALSE and does not touch the headers and prints an error
  157.  * using the error() routine.
  158.  */
  159. extern enum bool swap_object_headers(
  160.     struct mach_header *mh,
  161.     struct load_command *load_commands);
  162.  
  163. /*
  164.  * get_toc_byte_sex() guesses the byte sex of the table of contents of the
  165.  * library mapped in at the address, addr, of size, size based on the first
  166.  * object file's bytesex.  If it can't figure it out, because the library has
  167.  * no object file members or is malformed it will return UNKNOWN_BYTE_SEX.
  168.  */
  169. extern enum byte_sex get_toc_byte_sex(
  170.     char *addr,
  171.     unsigned long size);
  172.