Line | Branch | Exec | Source |
---|---|---|---|
1 | /* | ||
2 | * Copyright (c) 2022-2023, The Puppy RTOS Authors | ||
3 | * | ||
4 | * SPDX-License-Identifier: Apache-2.0 | ||
5 | */ | ||
6 | |||
7 | #include <puppy.h> | ||
8 | #include <puppy/kobj.h> | ||
9 | |||
10 | static int _g_errno; | ||
11 | |||
12 | 315 | int p_get_errno(void) | |
13 | { | ||
14 | 315 | struct _thread_obj *_thread = p_thread_self(); | |
15 |
1/2✓ Branch 0 taken 315 times.
✗ Branch 1 not taken.
|
315 | if (_thread) |
16 | 315 | return _thread->errno; | |
17 | else | ||
18 | ✗ | return _g_errno; | |
19 | } | ||
20 | |||
21 | 33 | void p_set_errno(int errno) | |
22 | { | ||
23 | 33 | struct _thread_obj *_thread = p_thread_self(); | |
24 |
1/2✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
|
33 | if (_thread) |
25 | 33 | _thread->errno = errno; | |
26 | else | ||
27 | ✗ | _g_errno = errno; | |
28 | 33 | } | |
29 | |||
30 | ✗ | const char *p_errno_str(int errno) | |
31 | { | ||
32 | ✗ | if (errno == P_EOK) return" OK"; | |
33 | ✗ | else if (errno == P_EINVAL) return" INVAL"; | |
34 | ✗ | else if (errno == P_EISR) return" ISR"; | |
35 | ✗ | else if (errno == P_ETIMEOUT) return" TIMEOUT"; | |
36 | ✗ | else if (errno == P_EBUSY) return" BUSY"; | |
37 | ✗ | else if (errno == P_ENOSYS) return" NOSYS"; | |
38 | ✗ | else if (errno == P_ESYSCALL) return" SYSCALL"; | |
39 | ✗ | else return "unknown"; | |
40 | } | ||
41 |