Repository navigation
Expand file tree
/
Copy patherror.h
More file actions
64 lines (53 loc) · 2.55 KB
/
Copy patherror.h
File metadata and controls
64 lines (53 loc) · 2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#ifndef ERROR_H
#define ERROR_H
#include <stdint.h>
/* ──────────────────────────────────────────────────────────────────
Codes d'erreur RTOS
────────────────────────────────────────────────────────────────── */
typedef enum {
E_OK = 0, /* Succès */
E_NOMEM = 1, /* Pas de mémoire disponible */
E_INVAL = 2, /* Argument invalide */
E_BUSY = 3, /* Ressource occupée */
E_TIMEOUT = 4, /* Timeout expiré */
E_PERM = 5, /* Permission refusée */
E_NOENT = 6, /* Fichier/Ressource non trouvé */
E_EXIST = 7, /* Le fichier existe déjà */
E_BADF = 8, /* Mauvais descripteur */
E_NOSPACE = 9, /* Pas d'espace disque */
E_DEADLK = 10, /* Détection de deadlock */
E_UNKNOWN = 11 /* Erreur inconnue */
} error_t;
/* ──────────────────────────────────────────────────────────────────
Macros utiles
────────────────────────────────────────────────────────────────── */
#define CHECK_RET(x) \
do { \
error_t _err = (x); \
if (_err != E_OK) { \
return _err; \
} \
} while(0)
#define CHECK_NULL(ptr, err_code) \
do { \
if (!(ptr)) { \
return (err_code); \
} \
} while(0)
#define ASSERT(cond, msg) \
do { \
if (!(cond)) { \
panic(msg, 0); \
} \
} while(0)
#define WARN_IF(cond, msg) \
do { \
if (cond) { \
log_msg(LOG_WARN, msg); \
} \
} while(0)
/* ──────────────────────────────────────────────────────────────────
Conversion erreur -> string
────────────────────────────────────────────────────────────────── */
const char* error_to_string(error_t err);
#endif /* ERROR_H */