diff options
-rw-r--r-- | src/gen-posix-lock-obj.c | 23 | ||||
-rw-r--r-- | src/posix-lock-obj.h | 5 | ||||
-rw-r--r-- | src/posix-lock.c | 8 |
3 files changed, 20 insertions, 16 deletions
diff --git a/src/gen-posix-lock-obj.c b/src/gen-posix-lock-obj.c index 5dbc6c6..7644c6f 100644 --- a/src/gen-posix-lock-obj.c +++ b/src/gen-posix-lock-obj.c @@ -70,30 +70,31 @@ main (void) "## File created by " PGM " - DO NOT EDIT\n" "## To be included by mkheader into gpg-error.h\n" "\n" - "typedef union\n" + "typedef struct\n" "{\n" - " struct {\n" + " long _vers;\n" + " union {\n" " volatile char _priv[%d];\n" - " long _vers;\n" - " } d;\n" - " long _x_align;\n" - " long *_xp_align;\n" + " long _x_align;\n" + " long *_xp_align;\n" + " } u;\n" "} gpgrt_lock_t;\n" "\n" - "#define GPGRT_LOCK_INITIALIZER {{{", + "#define GPGRT_LOCK_INITIALIZER {%d,{{", HOST_TRIPLET_STRING, - SIZEOF_PTHREAD_MUTEX_T); + SIZEOF_PTHREAD_MUTEX_T, + LOCK_ABI_VERSION); p = (unsigned char *)&mtx; for (i=0; i < sizeof mtx; i++) { if (i && !(i % 8)) - printf (" \\\n%*s", 34, ""); + printf (" \\\n%*s", 36, ""); printf ("%u", p[i]); if (i < sizeof mtx - 1) putchar (','); } - printf ("},%d}}\n", LOCK_ABI_VERSION); - fputs ("##\n" + fputs ("}}}\n" + "##\n" "## Loc" "al Variables:\n" "## mode: c\n" "## buffer-read-only: t\n" diff --git a/src/posix-lock-obj.h b/src/posix-lock-obj.h index a5a9ee7..7714d3c 100644 --- a/src/posix-lock-obj.h +++ b/src/posix-lock-obj.h @@ -24,8 +24,11 @@ typedef struct { - pthread_mutex_t mtx; long vers; + union { + pthread_mutex_t mtx; + long *dummy; + } u; } _gpgrt_lock_t; diff --git a/src/posix-lock.c b/src/posix-lock.c index 46e3a84..363cc09 100644 --- a/src/posix-lock.c +++ b/src/posix-lock.c @@ -122,7 +122,7 @@ gpgrt_lock_init (gpgrt_lock_t *lockhd) #if USE_POSIX_THREADS if (use_pthread_p()) { - rc = pthread_mutex_init (&lock->mtx, NULL); + rc = pthread_mutex_init (&lock->u.mtx, NULL); if (rc) rc = gpg_err_code_from_errno (rc); } @@ -145,7 +145,7 @@ gpgrt_lock_lock (gpgrt_lock_t *lockhd) #if USE_POSIX_THREADS if (use_pthread_p()) { - rc = pthread_mutex_lock (&lock->mtx); + rc = pthread_mutex_lock (&lock->u.mtx); if (rc) rc = gpg_err_code_from_errno (rc); } @@ -168,7 +168,7 @@ gpgrt_lock_unlock (gpgrt_lock_t *lockhd) #if USE_POSIX_THREADS if (use_pthread_p()) { - rc = pthread_mutex_unlock (&lock->mtx); + rc = pthread_mutex_unlock (&lock->u.mtx); if (rc) rc = gpg_err_code_from_errno (rc); } @@ -193,7 +193,7 @@ gpgrt_lock_destroy (gpgrt_lock_t *lockhd) #if USE_POSIX_THREADS if (use_pthread_p()) { - rc = pthread_mutex_destroy (&lock->mtx); + rc = pthread_mutex_destroy (&lock->u.mtx); if (rc) rc = gpg_err_code_from_errno (rc); else |