diff options
author | Werner Koch <[email protected]> | 2014-01-09 18:14:09 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2014-01-17 17:06:37 +0000 |
commit | e07538c0ed3c5cb3d870a490a4c12bef4375278a (patch) | |
tree | 147e33abcf92c0dc87ebb1f1b7363980a9194714 | |
parent | Extend the platform dependent build rules. (diff) | |
download | libgpg-error-e07538c0ed3c5cb3d870a490a4c12bef4375278a.tar.gz libgpg-error-e07538c0ed3c5cb3d870a490a4c12bef4375278a.zip |
Move version number first in the Posix lock-obj.
* src/posix-lock-obj.h (_gpgrt_lock_t): Swap VERS and MTX and put MTX
into a union.
* src/posix-lock.c (gpgrt_lock_lock): Adjust for this change.
* src/gen-posix-lock-obj.c (main): Change output accordingly.
Signed-off-by: Werner Koch <[email protected]>
-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 |