《操作系统》的实验代码。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.6 KiB

10 years ago
  1. #ifndef __USER_LIBS_ULIB_H__
  2. #define __USER_LIBS_ULIB_H__
  3. #include <defs.h>
  4. void __warn(const char *file, int line, const char *fmt, ...);
  5. void __noreturn __panic(const char *file, int line, const char *fmt, ...);
  6. #define warn(...) \
  7. __warn(__FILE__, __LINE__, __VA_ARGS__)
  8. #define panic(...) \
  9. __panic(__FILE__, __LINE__, __VA_ARGS__)
  10. #define assert(x) \
  11. do { \
  12. if (!(x)) { \
  13. panic("assertion failed: %s", #x); \
  14. } \
  15. } while (0)
  16. // static_assert(x) will generate a compile-time error if 'x' is false.
  17. #define static_assert(x) \
  18. switch (x) { case 0: case (x): ; }
  19. int fprintf(int fd, const char *fmt, ...);
  20. void __noreturn exit(int error_code);
  21. int fork(void);
  22. int wait(void);
  23. int waitpid(int pid, int *store);
  24. void yield(void);
  25. int kill(int pid);
  26. int getpid(void);
  27. void print_pgdir(void);
  28. int sleep(unsigned int time);
  29. unsigned int gettime_msec(void);
  30. int __exec(const char *name, const char **argv);
  31. #define __exec0(name, path, ...) \
  32. ({ const char *argv[] = {path, ##__VA_ARGS__, NULL}; __exec(name, argv); })
  33. #define exec(path, ...) __exec0(NULL, path, ##__VA_ARGS__)
  34. #define nexec(name, path, ...) __exec0(name, path, ##__VA_ARGS__)
  35. void lab6_set_priority(uint32_t priority); //only for lab6
  36. #endif /* !__USER_LIBS_ULIB_H__ */