2 #include "thread-utils.h" /* for GIT_TLS */
5 /* compile-time constant initialization required */
6 GIT_TLS
int git_errno
= 0;
8 #elif defined(GIT_HAS_PTHREAD)
10 static pthread_key_t errno_key
;
12 static void init_errno(void) __attribute__((constructor
));
13 static void init_errno(void)
15 pthread_key_create(&errno_key
, free
);
18 int *git__errno_storage(void)
20 int *e
= pthread_getspecific(errno_key
);
23 e
= calloc(1, sizeof(*e
));
24 #define calloc(a,b) GIT__FORBID_MALLOC
25 pthread_setspecific(errno_key
, e
);
36 { GIT_ENOTOID
, "Not a git oid" },
37 { GIT_ENOTFOUND
, "Object does not exist in the scope searched" },
38 { GIT_ENOMEM
, "Not enough space" },
41 const char *git_strerror(int num
)
45 if (num
== GIT_EOSERR
)
46 return strerror(errno
);
47 for (i
= 0; i
< ARRAY_SIZE(error_codes
); i
++)
48 if (num
== error_codes
[i
].num
)
49 return error_codes
[i
].str
;
51 return "Unknown error";