1
0

lib9.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * This file is part of the UCB release of Plan 9. It is subject to the license
  3. * terms in the LICENSE file found in the top-level directory of this
  4. * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
  5. * part of the UCB release of Plan 9, including this file, may be copied,
  6. * modified, propagated, or distributed except according to the terms contained
  7. * in the LICENSE file.
  8. */
  9. #ifndef __LIB9_H
  10. #define __LIB9_H
  11. #if !defined(_RESEARCH_SOURCE) && !defined(_PLAN9_SOURCE)
  12. This header file is an extension to ANSI/POSIX
  13. #endif
  14. #pragma lib "/$M/lib/ape/lib9.a"
  15. #include <u.h> /* ick; need Rune defined below */
  16. #define MORDER 0x0003 /* mask for bits defining order of mounting */
  17. #define MREPL 0x0000 /* mount replaces object */
  18. #define MBEFORE 0x0001 /* mount goes before others in union directory */
  19. #define MAFTER 0x0002 /* mount goes after others in union directory */
  20. #define MCREATE 0x0004 /* permit creation in mounted directory */
  21. #define MRECOV 0x0008 /* perform recovery if mount channel is lost */
  22. #define MCACHE 0x0010 /* cache some data */
  23. #define MMASK 0x0007 /* all bits on */
  24. #define FORKPG 1
  25. #define FORKEG 2
  26. #define FORKFD 4
  27. #define SG_RONLY 0040 /* read only */
  28. #define SG_CEXEC 0100 /* detach on exec */
  29. enum
  30. {
  31. RFNAMEG = (1<<0),
  32. RFENVG = (1<<1),
  33. RFFDG = (1<<2),
  34. RFNOTEG = (1<<3),
  35. RFPROC = (1<<4),
  36. RFMEM = (1<<5),
  37. RFNOWAIT = (1<<6),
  38. RFCNAMEG = (1<<10),
  39. RFCENVG = (1<<11),
  40. RFCFDG = (1<<12),
  41. RFREND = (1<<13)
  42. };
  43. extern char *argv0;
  44. #define ARGBEGIN for((argv0||(argv0=*argv)),argv++,argc--;\
  45. argv[0] && argv[0][0]=='-' && argv[0][1];\
  46. argc--, argv++) {\
  47. char *_args, *_argt;\
  48. Rune _argc;\
  49. _args = &argv[0][1];\
  50. if(_args[0]=='-' && _args[1]==0){\
  51. argc--; argv++; break;\
  52. }\
  53. _argc = 0;\
  54. while(*_args && (_args += chartorune(&_argc, _args)))\
  55. switch(_argc)
  56. #define ARGEND SET(_argt);USED(_argt,_argc,_args);}USED(argv, argc);
  57. #define ARGF() (_argt=_args, _args="",\
  58. (*_argt? _argt: argv[1]? (argc--, *++argv): 0))
  59. #define EARGF(x) (_argt=_args, _args="",\
  60. (*_argt? _argt: argv[1]? (argc--, *++argv): ((x), abort(), (char*)0)))
  61. #define ARGC() _argc
  62. extern int errstr(char*, unsigned int);
  63. extern int bind(char*, char*, int);
  64. extern int mount(int, int, char*, int, char*);
  65. extern int unmount(char*, char*);
  66. extern int rfork(int);
  67. extern int segattach(int, char*, void*, unsigned long);
  68. extern int segbrk(void*, void*);
  69. extern int segdetach(void*);
  70. extern int segflush(void*, unsigned long);
  71. extern int segfree(void*, unsigned long);
  72. extern unsigned long rendezvous(unsigned long, unsigned long);
  73. extern unsigned long getfcr(void);
  74. extern unsigned long getfsr(void);
  75. extern void setfcr(unsigned long);
  76. extern void setfsr(unsigned long);
  77. #endif