home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / e / emxdev8f.zip / OS2THUNK.H < prev    next >
Text File  |  1992-10-31  |  1KB  |  34 lines

  1. /* os2thunk.h (emx+gcc) */
  2.  
  3. #if !defined (_OS2THUNK_H)
  4.  
  5. #define _OS2THUNK_H
  6.  
  7. typedef unsigned long _far16ptr;
  8.  
  9. _far16ptr _emx_32to16 (void *ptr);
  10. void *_emx_16to32 (_far16ptr ptr);
  11.  
  12. unsigned long _emx_thunk1 (void *args, void *fun);
  13.  
  14. #define _THUNK_PROLOG(SIZE) \
  15.   ({ char _tb[(SIZE)+4]; void *_tp = _tb + sizeof (_tb); \
  16.        *(unsigned long *)_tb = (SIZE);
  17.  
  18. #define _THUNK_CHAR(ARG)  _THUNK_SHORT (ARG)
  19. #define _THUNK_SHORT(ARG) *--((unsigned short *)_tp) = (ARG)
  20. #define _THUNK_LONG(ARG)  *--((unsigned long *)_tp) = (ARG)
  21. #define _THUNK_FLAT(ARG)  _THUNK_LONG (_emx_32to16 (ARG))
  22. #define _THUNK_FAR16(ARG) _THUNK_LONG (ARG)
  23.  
  24. #define _THUNK_FUNCTION(FUN) _16_##FUN
  25.  
  26. #define _THUNK_CALL(FUN) _emx_thunk1 (_tb, (void *)(_16_##FUN)); })
  27.  
  28. #define MAKE16P(sel,off)   ((_far16ptr)((sel) << 16 | (off)))
  29. #define MAKEP(sel,off)     _emx_16to32 (MAKE16P (sel, off))
  30. #define SELECTOROF(farptr) ((SEL)((farptr) >> 16))
  31. #define OFFSETOF(farptr)   ((USHORT)(farptr))
  32.  
  33. #endif /* !defined (_OS2THUNK_H) */
  34.