home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / zip / gnu / includ87.lzh / INCLUD87 / MINTBIND.H < prev    next >
C/C++ Source or Header  |  1993-07-30  |  11KB  |  331 lines

  1. #ifndef _MINTBIND_H
  2. #define _MINTBIND_H
  3.  
  4. #ifndef _OSBIND_H
  5. #include <osbind.h>
  6. #endif
  7.  
  8. #ifdef __cplusplus
  9. extern "C" {
  10. #endif
  11.  
  12. #ifdef __TURBOC__
  13.  
  14. /* we supply a library of bindings for TurboC / PureC */
  15.  
  16. int Syield( void );                /* GEMDOS 0xff */
  17. int Fpipe( short *ptr );            /* GEMDOS 0x100 */
  18. long Fcntl( int f, long arg, int cmd);        /* GEMDOS 0x104 */
  19. #define Fcntl(f, arg, cmd) Fcntl(f, (long)(arg), cmd)
  20. long Finstat( int f );                /* GEMDOS 0x105 */
  21. long Foutstat( int f );                /* GEMDOS 0x106 */
  22. long Fgetchar(int f, int mode);            /* GEMDOS 0x107 */
  23. long Fputchar( int f, long c, int mode );     /* GEMDOS 0x108 */
  24. long Pwait( void );                /* GEMDOS 0x109 */
  25. int Pnice( int delta );                /* GEMDOS 0x10a */
  26. int Pgetpid( void );                /* GEMDOS 0x10b */
  27. int Pgetppid( void );                /* GEMDOS 0x10c */
  28. int Pgetpgrp( void );                /* GEMDOS 0x10d */
  29. int Psetpgrp(int pid, int newgrp);        /* GEMDOS 0x10e */
  30. int Pgetuid( void );                /* GEMDOS 0x10f */
  31. int Psetuid( int id );                /* GEMDOS 0x110 */
  32. int Pkill( int pid, int sig );            /* GEMDOS 0x111 */
  33. long Psignal(int sig, long handler);        /* GEMDOS 0x112 */
  34. long Pvfork( void );                /* GEMDOS 0x113 */
  35. int Pgetgid( void );                /* GEMDOS 0x114 */
  36. int Psetgid(int id);                /* GEMDOS 0x115 */
  37. long Psigblock(unsigned long mask);        /* GEMDOS 0x116 */
  38. long Psigsetmask(unsigned long mask);        /* GEMDOS 0x117 */
  39. long Pusrval(long arg);                /* GEMDOS 0x118 */
  40. int Pdomain(int newdom);            /* GEMDOS 0x119 */
  41. void Psigreturn( void );            /* GEMDOS 0x11a */
  42. long Pfork( void );                /* GEMDOS 0x11b */
  43. long Pwait3(int flag, long *rusage);        /* GEMDOS 0x11c */
  44. int Fselect(unsigned int timeout, long *rfds, long *wfds, long *xfds); /* GEMDOS 0x11d */
  45. int Prusage( long r[8] );            /* GEMDOS 0x11e */
  46. long Psetlimit(int lim, long value);        /* GEMDOS 0x11f */
  47. long Talarm( long secs );            /* GEMDOS 0x120 */
  48. void Pause( void );                /* GEMDOS 0x121 */
  49. long Sysconf( int n );                /* GEMDOS 0x122 */
  50. long Psigpending( void );            /* GEMDOS 0x123 */
  51. long Dpathconf( const char *name, int n );    /* GEMDOS 0x124 */
  52. long Pmsg( int mode, long mbox, void *msg );     /* GEMDOS 0x125 */
  53. long Fmidipipe( int pid, int in, int out );    /* GEMDOS 0x126 */
  54. int Prenice( int pid, int delta );        /* GEMDOS 0x127 */
  55. long Dopendir( const char *name, int flag );    /* GEMDOS 0x128 */
  56. long Dreaddir( int buflen, long dir, char *buf); /*GEMDOS 0x129 */
  57. #define Dreaddir(buflen, dir, buf) Dreaddir(buflen, (long)(dir), buf)
  58. long Drewinddir( long dir );            /* GEMDOS 0x12a */
  59. #define Drewinddir(dir) Drewinddir((long)(dir))
  60. long Dclosedir( long dir );            /* GEMDOS 0x12b */
  61. #define Dclosedir(dir) Dclosedir((long)(dir))
  62. long Fxattr( int flag, char *name, void *buf );    /* GEMDOS 0x12c */
  63. long Flink( char *oldname, char *newname );    /* GEMDOS 0x12d */
  64. long Fsymlink( char *oldname, char *newname );    /* GEMDOS 0x12e */
  65. long Freadlink( int siz, char *buf, char *name); /*GEMDOS 0x12f */
  66. long Dcntl( int cmd, char *name, long arg );    /* GEMDOS 0x130 */
  67. long Fchown( char *name, int uid, int gid);    /* GEMDOS 0x131 */
  68. long Fchmod( char *name, int mode );        /* GEMDOS 0x132 */
  69. int Pumask( int mask );                /* GEMDOS 0x133 */
  70. long Psemaphore(int mode, long id, long timeout); /* GEMDOS 0x134 */
  71. int Dlock( int mode, int drive );        /* GEMDOS 0x135 */
  72. void Psigpause( unsigned long mask);        /* GEMDOS 0x136 */
  73. long Psigaction(int sig, long act, long oact);    /* GEMDOS 0x137 */
  74. #define Psigaction(sig, act, oact) \
  75.     Psigaction(sig, (long)(act), (long)(oact))
  76. int Pgeteuid( void );                /* GEMDOS 0x138 */
  77. int Pgetegid( void );                /* GEMDOS 0x139 */
  78. int Pwaitpid(int pid, int flag, long *rusage);    /* GEMDOS 0x13a */
  79. long Dgetcwd(char *path, int drv, int size);    /* GEMDOS 0x13b */
  80. long Salert(char *msg);                /* GEMDOS 0x13c */
  81.  
  82. #else /* !__TURBOC__ */
  83.  
  84. #ifdef __GNUC_INLINE__
  85. #define trap_1_wwlw(n, a, b, c)                        \
  86. ({                                    \
  87.     register long retvalue __asm__("d0");                \
  88.     short _a = (short)(a);                        \
  89.     long  _b = (long) (b);                        \
  90.     short  _c = (short) (c);                    \
  91.                                         \
  92.     __asm__ volatile                        \
  93.     ("\
  94.         movw    %4,sp@-; \
  95.         movl    %3,sp@-; \
  96.         movw    %2,sp@-; \
  97.         movw    %1,sp@-; \
  98.         trap    #1;    \
  99.         lea    sp@(10),sp " \
  100.     : "=r"(retvalue)            /* outputs */        \
  101.     : "g"(n), "r"(_a), "r"(_b), "r"(_c)     /* inputs  */        \
  102.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  103.     );                                \
  104.     retvalue;                            \
  105. })
  106.  
  107. #define trap_1_wwww(n, a, b, c)                        \
  108. ({                                    \
  109.     register long retvalue __asm__("d0");                \
  110.     short _a = (short)(a);                        \
  111.     short  _b = (short)(b);                        \
  112.     short  _c = (short)(c);                        \
  113.                                         \
  114.     __asm__ volatile                        \
  115.     ("\
  116.         movw    %4,sp@-; \
  117.         movw    %3,sp@-; \
  118.         movw    %2,sp@-; \
  119.         movw    %1,sp@-; \
  120.         trap    #1;    \
  121.         addqw    #8,sp "                    \
  122.     : "=r"(retvalue)            /* outputs */        \
  123.     : "g"(n), "r"(_a), "r"(_b), "r"(_c)     /* inputs  */        \
  124.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  125.     );                                \
  126.     retvalue;                            \
  127. })
  128.  
  129. #define trap_1_wwwl(n, a, b, c)                        \
  130. ({                                    \
  131.     register long retvalue __asm__("d0");                \
  132.     short _a = (short)(a);                        \
  133.     short  _b = (short)(b);                        \
  134.     long  _c = (long)(c);                        \
  135.                                         \
  136.     __asm__ volatile                        \
  137.     ("\
  138.         movl    %4,sp@-; \
  139.         movw    %3,sp@-; \
  140.         movw    %2,sp@-; \
  141.         movw    %1,sp@-; \
  142.         trap    #1;    \
  143.         lea     sp@(10),sp "                    \
  144.     : "=r"(retvalue)            /* outputs */        \
  145.     : "g"(n), "r"(_a), "r"(_b), "r"(_c)     /* inputs  */        \
  146.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  147.     );                                \
  148.     retvalue;                            \
  149. })
  150.  
  151. #define trap_1_wwl(n, a, b)                        \
  152. ({                                    \
  153.     register long retvalue __asm__("d0");                \
  154.     short _a = (short)(a);                        \
  155.     long  _b = (long) (b);                        \
  156.                                         \
  157.     __asm__ volatile                        \
  158.     ("\
  159.         movl    %3,sp@-; \
  160.         movw    %2,sp@-; \
  161.         movw    %1,sp@-; \
  162.         trap    #1;    \
  163.         addqw    #8,sp "                    \
  164.     : "=r"(retvalue)            /* outputs */        \
  165.     : "g"(n), "r"(_a), "r"(_b)        /* inputs  */        \
  166.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  167.     );                                \
  168.     retvalue;                            \
  169. })
  170.  
  171. #else
  172.  
  173. #ifdef __GNUC__
  174. # ifndef __MSHORT__
  175. #  define __LONG_TRAPS__
  176. # endif
  177. #endif
  178.  
  179. #ifndef __LONG_TRAPS__
  180. # ifndef trap_1_w
  181. #  define trap_1_w(n)        gemdos(n)
  182. #  define trap_1_wl(n,a)        gemdos(n, (long)(a))
  183. #  define trap_1_wll(n, a, b)    gemdos(n, (long)(a), (long)(b))
  184. #  define trap_1_ww(n,a)        gemdos(n, a)
  185. #  define trap_1_www(n,a,b)    gemdos(n, a, b)
  186. #  define trap_1_wwlll(n,a,b,c,d) gemdos(n, a, (long)(b), (long)(c), (long)(d))
  187. #  define trap_1_wwll(n, a, b, c)    gemdos(n, a, (long)(b), (long)(c))
  188. #  define trap_1_wlw(n, a, b)    gemdos(n, (long)(a), b)
  189. #  define trap_1_wlww(n, a, b, c)    gemdos(n, (long)(a), b, c)
  190. #  define trap_13_w(n)        bios(n)
  191. #  define trap_14_w(n)        xbios(n)
  192. # endif
  193. # define trap_1_wwlw(n,a,b,c)    gemdos(n, a, (long)(b), c)
  194. # define trap_1_wwww(n,a,b,c)    gemdos(n, a, b, c)
  195. # define trap_1_wwl(n, a, b)    gemdos(n, a, (long)(b))
  196. # define trap_1_wwwl(n,a,b,c)    gemdos(n, a, b, (long)(c))
  197. #endif /* __LONG_TRAPS__ */
  198.  
  199. #endif /* __GNUC_INLINE__ */
  200.  
  201. #define    Syield()                        \
  202.         (int)trap_1_w(0xff)
  203. #define Fpipe(ptr)                        \
  204.         (int)trap_1_wl(0x100, (long)(ptr))
  205. #define Fcntl(f, arg, cmd)                    \
  206.         trap_1_wwlw(0x104, (short)(f), (long)(arg), (short)(cmd))
  207. #define Finstat(f)                        \
  208.         trap_1_ww(0x105, (short)(f))
  209. #define Foutstat(f)                        \
  210.         trap_1_ww(0x106, (short)(f))
  211. #define Fgetchar(f, mode)                    \
  212.         trap_1_www(0x107, (short)(f), (short)(mode))
  213. #define Fputchar(f, ch, mode)                    \
  214.         trap_1_wwlw(0x108, (short)(f), (long)(ch), (short)(mode))
  215.  
  216. #define Pwait()                            \
  217.         trap_1_w(0x109)
  218. #define Pnice(delta)                        \
  219.         (int)trap_1_ww(0x10a, (short)(delta))
  220. #define Pgetpid()                        \
  221.         (int)trap_1_w(0x10b)
  222. #define Pgetppid()                        \
  223.         (int)trap_1_w(0x10c)
  224. #define Pgetpgrp()                        \
  225.         (int)trap_1_w(0x10d)
  226. #define Psetpgrp(pid, grp)                    \
  227.         (int)trap_1_www(0x10e, (short)(pid), (short)(grp))
  228. #define Pgetuid()                        \
  229.         (int)trap_1_w(0x10f)
  230. #define Psetuid(id)                        \
  231.         (int)trap_1_ww(0x110, (short)(id))
  232. #define Pkill(pid, sig)                        \
  233.         (int)trap_1_www(0x111, (short)(pid), (short)(sig))
  234. #define Psignal(sig, handler)                    \
  235.         trap_1_wwl(0x112, (short)(sig), (long)(handler))
  236. #define Pvfork()                        \
  237.         trap_1_w(0x113)
  238. #define Pgetgid()                        \
  239.         (int)trap_1_w(0x114)
  240. #define Psetgid(id)                        \
  241.         (int)trap_1_ww(0x115, (short)(id))
  242. #define Psigblock(mask)                        \
  243.         trap_1_wl(0x116, (unsigned long)(mask))
  244. #define Psigsetmask(mask)                    \
  245.         trap_1_wl(0x117, (unsigned long)(mask))
  246. #define Pusrval(arg)                        \
  247.         trap_1_wl(0x118, (long)(arg))
  248. #define Pdomain(arg)                        \
  249.         (int)trap_1_ww(0x119, (short)(arg))
  250. #define Psigreturn()                        \
  251.         (void)trap_1_w(0x11a)
  252. #define Pfork()                            \
  253.         trap_1_w(0x11b)
  254. #define Pwait3(flag, rusage)                    \
  255.         trap_1_wwl(0x11c, (short)(flag), (long)(rusage))
  256. #define Fselect(time, rfd, wfd, xfd)                \
  257.         (int)trap_1_wwlll(0x11d, (unsigned short)(time), (long)(rfd), \
  258.                 (long)(wfd), (long)(xfd))
  259. #define Prusage(rsp)                        \
  260.         (int)trap_1_wl(0x11e, (long)(rsp))
  261. #define Psetlimit(i, val)                    \
  262.         trap_1_wwl(0x11f, (short)(i), (long)(val))
  263.  
  264. #define Talarm(sec)                        \
  265.         trap_1_wl(0x120, (long)(sec))
  266. #define Pause()                            \
  267.         (void)trap_1_w(0x121)
  268. #define Sysconf(n)                        \
  269.         trap_1_ww(0x122, (short)(n))
  270. #define Psigpending()                        \
  271.         trap_1_w(0x123)
  272. #define Dpathconf(name, which)                    \
  273.         trap_1_wlw(0x124, (long)(name), (short)(which))
  274.  
  275. #define Pmsg(mode, mbox, msg)                    \
  276.         trap_1_wwll(0x125, (short)(mode), (long)(mbox), (long)(msg))
  277. #define Fmidipipe(pid, in, out)                    \
  278.         trap_1_wwww(0x126, (short)(pid), (short)(in),(short)(out))
  279. #define Prenice(pid, delta)                    \
  280.         (int)trap_1_www(0x127, (short)(pid), (short)(delta))
  281. #define Dopendir(name, flag)                    \
  282.         trap_1_wlw(0x128, (long)(name), (short)(flag))
  283. #define Dreaddir(len, handle, buf)                \
  284.         trap_1_wwll(0x129, (short)(len), (long)(handle), (long)(buf))
  285. #define Drewinddir(handle)                    \
  286.         trap_1_wl(0x12a, (long)(handle))
  287. #define Dclosedir(handle)                    \
  288.         trap_1_wl(0x12b, (long)(handle))
  289. #define Fxattr(flag, name, buf)                    \
  290.         trap_1_wwll(0x12c, (short)(flag), (long)(name), (long)(buf))
  291. #define Flink(old, new)                        \
  292.         trap_1_wll(0x12d, (long)(old), (long)(new))
  293. #define Fsymlink(old, new)                    \
  294.         trap_1_wll(0x12e, (long)(old), (long)(new))
  295. #define Freadlink(siz, buf, linknm)                \
  296.         trap_1_wwll(0x12f, (short)(siz), (long)(buf), (long)(linknm))
  297. #define Dcntl(cmd, name, arg)                    \
  298.         trap_1_wwll(0x130, (short)(cmd), (long)(name), (long)(arg))
  299. #define Fchown(name, uid, gid)                    \
  300.         trap_1_wlww(0x131, (long)(name), (short)(uid), (short)(gid))
  301. #define Fchmod(name, mode)                    \
  302.         trap_1_wlw(0x132, (long)(name), (short)(mode))
  303. #define Pumask(mask)                        \
  304.         (int)trap_1_ww(0x133, (short)(mask))
  305. #define Psemaphore(mode, id, tmout)                \
  306.         trap_1_wwll(0x134, (short)(mode), (long)(id), (long)(tmout))
  307. #define Dlock(mode, drive)                    \
  308.         (int)trap_1_www(0x135, (short)(mode), (short)(drive))
  309. #define Psigpause(mask)                        \
  310.         (void)trap_1_wl(0x136, (unsigned long)(mask))
  311. #define Psigaction(sig, act, oact)                    \
  312.         trap_1_wwll(0x137, (short)(sig), (long)(act), (long)(oact))
  313. #define Pgeteuid()                        \
  314.         (int)trap_1_w(0x138)
  315. #define Pgetegid()                        \
  316.         (int)trap_1_w(0x139)
  317. #define Pwaitpid(pid,flag, rusage)                \
  318.         trap_1_wwwl(0x13a, (short)(pid), (short)(flag), (long)(rusage))
  319. #define Dgetcwd(path, drv, size)                \
  320.         trap_1_wlww(0x13b, (long)(path), (short)(drv), (short)(size))
  321. #define Salert(msg)                        \
  322.         trap_1_wl(0x13c, (long)(msg))
  323.  
  324. #endif /* __TURBOC__ */
  325.  
  326. #ifdef __cplusplus
  327. }
  328. #endif
  329.  
  330. #endif /* _MINTBIND_H */
  331.