mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-28 06:47:53 +00:00

The Mach-O format does not permit gcc to implement the __thread TLS specification, so we must instead emulate it using a single int cell allocated from memory and stored inside of the thread specific data associated with the current pthread. What makes this tricky is git_errno must be a valid lvalue, so we really need to return a pointer to the caller and deference it as part of the git_errno macro. The GCC-specific __attribute__((constructor)) extension is used to ensure the pthread_key_t is allocated before any Git functions are executed in the library, as this is necessary to access our thread specific storage. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
15 lines
330 B
C
15 lines
330 B
C
#include "test_lib.h"
|
|
#include "errors.h"
|
|
#include <string.h>
|
|
|
|
BEGIN_TEST(errno_zero_on_init)
|
|
must_be_true(git_errno == 0);
|
|
END_TEST
|
|
|
|
BEGIN_TEST(set_ENOTOID)
|
|
must_be_true(GIT_ENOTOID != 0);
|
|
git_errno = GIT_ENOTOID;
|
|
must_be_true(git_errno == GIT_ENOTOID);
|
|
must_pass(strcmp(git_strerror(git_errno), "Not a git oid"));
|
|
END_TEST
|