proc_uptime.c 887 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. * Copyright (c) 2006-2023, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. */
  9. #include "proc.h"
  10. #include "procfs.h"
  11. #include <rthw.h>
  12. #include <rtdbg.h>
  13. #include <fcntl.h>
  14. #include <errno.h>
  15. #include <dfs_dentry.h>
  16. static int single_show(struct dfs_seq_file *seq, void *data)
  17. {
  18. dfs_seq_printf(seq, "%lu.%02lu %lu.%02lu\n",
  19. (unsigned long)rt_tick_get_millisecond() / 1000, (unsigned long)(rt_tick_get_millisecond() % 1000) / 100,
  20. (unsigned long)rt_tick_get_millisecond() / 1000, (unsigned long)(rt_tick_get_millisecond() % 1000) / 100);
  21. return 0;
  22. }
  23. int proc_uptime_init(void)
  24. {
  25. struct proc_dentry *dentry = proc_create_single_data("uptime", 0, NULL, single_show, NULL);
  26. proc_release(dentry);
  27. return 0;
  28. }
  29. INIT_ENV_EXPORT(proc_uptime_init);