home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / dev / gcc / ixemulsrc.lha / ixemul / include / packets.h < prev    next >
C/C++ Source or Header  |  1996-12-11  |  3KB  |  79 lines

  1. /*
  2.  *  This file is part of ixemul.library for the Amiga.
  3.  *  Copyright (C) 1991, 1992  Markus M. Wild
  4.  *
  5.  *  This library is free software; you can redistribute it and/or
  6.  *  modify it under the terms of the GNU Library General Public
  7.  *  License as published by the Free Software Foundation; either
  8.  *  version 2 of the License, or (at your option) any later version.
  9.  *
  10.  *  This library is distributed in the hope that it will be useful,
  11.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.  *  Library General Public License for more details.
  14.  *
  15.  *  You should have received a copy of the GNU Library General Public
  16.  *  License along with this library; if not, write to the Free
  17.  *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  */
  19.  
  20. #ifndef _PACKETS_H
  21. #define _PACKETS_H
  22.  
  23. #define PutPacket(port,pack) PutMsg((port), (struct Message *)(pack))
  24.  
  25. #define GetPacket(port) ((struct StandardPacket *)GetMsg(port))
  26.  
  27. /***************************************************************************/
  28.  
  29. #define LastResult(f) ((f)->f_sp.sp_Pkt.dp_Res1)
  30. #define LastError(f) ((f)->f_sp.sp_Pkt.dp_Res2)
  31.  
  32. #define SelLastResult(f) ((f)->f_select_sp.sp_Pkt.dp_Res1)
  33. #define SelLastError(f) ((f)->f_select_sp.sp_Pkt.dp_Res2)
  34.  
  35. /***************************************************************************/
  36.  
  37. #define SendPacket0(fp,port,act) \
  38.   ((fp)->f_sp.sp_Pkt.dp_Port = (port), (fp)->f_sp.sp_Pkt.dp_Type = (act), \
  39.   PutPacket((fp)->f_fh->fh_Type, &(fp)->f_sp))
  40.  
  41. #define SendPacket1(fp,port,act,arg1) \
  42.   ((fp)->f_sp.sp_Pkt.dp_Port = (port), (fp)->f_sp.sp_Pkt.dp_Type = (act), \
  43.   (fp)->f_sp.sp_Pkt.dp_Arg1 = (arg1), \
  44.   PutPacket((fp)->f_fh->fh_Type, &(fp)->f_sp))
  45.  
  46. #define SelSendPacket1(fp,port,act,arg1) \
  47.   ((fp)->f_select_sp.sp_Pkt.dp_Port = (port), (fp)->f_select_sp.sp_Pkt.dp_Type = (act), \
  48.   (fp)->f_select_sp.sp_Pkt.dp_Arg1 = (arg1), \
  49.   PutPacket((fp)->f_fh->fh_Type, &(fp)->f_select_sp))
  50.  
  51. #define SendPacket2(fp,port,act,arg1,arg2) \
  52.   ((fp)->f_sp.sp_Pkt.dp_Port = (port), (fp)->f_sp.sp_Pkt.dp_Type = (act), \
  53.   (fp)->f_sp.sp_Pkt.dp_Arg1 = (arg1), (fp)->f_sp.sp_Pkt.dp_Arg2 = (arg2), \
  54.   PutPacket((fp)->f_fh->fh_Type, &(fp)->f_sp))
  55.  
  56. #define SendPacket3(fp,port,act,arg1,arg2,arg3) \
  57.   ((fp)->f_sp.sp_Pkt.dp_Port = (port), (fp)->f_sp.sp_Pkt.dp_Type = (act), \
  58.   (fp)->f_sp.sp_Pkt.dp_Arg1 = (arg1), (fp)->f_sp.sp_Pkt.dp_Arg2 = (arg2), \
  59.   (fp)->f_sp.sp_Pkt.dp_Arg3 = (arg3), \
  60.   PutPacket((fp)->f_fh->fh_Type, &((fp)->f_sp)))
  61.  
  62. #define SendPacket4(fp,port,act,arg1,arg2,arg3,arg4) \
  63.   ((fp)->f_sp.sp_Pkt.dp_Port = (port), (fp)->f_sp.sp_Pkt.dp_Type = (act), \
  64.   (fp)->f_sp.sp_Pkt.dp_Arg1 = (arg1), (fp)->f_sp.sp_Pkt.dp_Arg2 = (arg2), \
  65.   (fp)->f_sp.sp_Pkt.dp_Arg3 = (arg3), (fp)->f_sp.sp_Pkt.dp_Arg4 = (arg4), \
  66.   PutPacket((fp)->f_fh->fh_Type, &(fp)->f_sp))
  67.  
  68. /***************************************************************************/
  69.  
  70. #define HANDLER_NIL(fp) (!(fp)->f_fh->fh_Type)
  71.  
  72. #define CTOBPTR(ptr) (((long)(ptr)) >> 2)
  73. #define BTOCPTR(ptr) ((void *)((ptr) << 2))
  74.  
  75. /* this version only works for word-aligned data as you get it from alloca()! */
  76. #define LONG_ALIGN(ptr) ((void *)((((long)(ptr))&3)?((long)ptr)+2:(long)ptr))
  77.  
  78. #endif /* _PACKETS_H */
  79.