[git] GPG-ERROR - branch, master, updated. libgpg-error-1.12-14-ge07538c

by Werner Koch cvs at cvs.gnupg.org
Fri Jan 17 18:08:46 CET 2014


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Error codes used by GnuPG et al.".

The branch, master has been updated
       via  e07538c0ed3c5cb3d870a490a4c12bef4375278a (commit)
       via  d83b12213231443b93de39863b916ada6232035a (commit)
      from  4f9b13e99bdfed886dadfd1b70a69af3747ebc98 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit e07538c0ed3c5cb3d870a490a4c12bef4375278a
Author: Werner Koch <wk at gnupg.org>
Date:   Thu Jan 9 19:14:09 2014 +0100

    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 <wk at gnupg.org>

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

commit d83b12213231443b93de39863b916ada6232035a
Author: Werner Koch <wk at gnupg.org>
Date:   Thu Jan 9 19:14:09 2014 +0100

    Extend the platform dependent build rules.
    
    * src/mkheader.c (mk_include_name): New.
    (include_file): Implement '&' substitution.
    (try_include_file): New.
    (write_special): Use try_include_file and syscfg/.
    (main): Add a new arg.
    * configure.ac (CROSS_COMPILING): New am_conditional.
    (HOST_TRIPLET_STRING): New ac_define.
    * src/gen-posix-lock-obj.c (main): Print the host triplet.
    * src/w32-lock-obj-pub.in: Move to ...
    * src/syscfg/lock-obj-pub.mingw32.h: here.
    * src/Makefile.am (lock_obj_pub): New.
    (pre_mkheader_cmds): New.
    (gpg-error.h): Run pre_mkheader_cmds.
    (parts_of_gpg_error_h, lock-obj-pub.native.h): Do not use when
    cross-compiling.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/README b/README
index 73af551..3d4640c 100644
--- a/README
+++ b/README
@@ -95,6 +95,30 @@ version:
    ./autogen.sh --build-w64
 
 
+Cross-Compiling
+---------------
+
+Libgpg-error needs to figure out some platform specific properties.
+These are used to build the platform specific gpg-error.h file.  The
+detection is done during build time but can't be done when
+cross-compiling.  Thus if you run into an error during building you
+need to figure out these values.  You may use these commands:
+
+  build="$(build-aux/config.guess)"
+  ./configure --prefix=TARGETDIR --host=TARGET --build=$build
+  cd src
+  make gen-posix-lock-obj
+  scp gen-posix-lock-obj TARGET:
+  ssh TARGET ./gen-posix-lock-obj >tmp.h
+  mv tmp.h "syscfg/$(awk 'NR==1 {print $2}' tmp.h)"
+
+If you are using a VPATH build adjust accordingly.  If this all works
+for you (make sure to run the test programs on the target platform),
+please send the generated file to the gnupg-devel mailing list so that
+we can include it in the next release.
+
+
+
 Known Problems
 --------------
 
diff --git a/configure.ac b/configure.ac
index 3d1e12f..21a36e9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -202,6 +202,9 @@ fi
 AM_CONDITIONAL(HAVE_W32_SYSTEM, test "$have_w32_system" = yes)
 AM_CONDITIONAL(HAVE_W64_SYSTEM, test "$have_w64_system" = yes)
 AM_CONDITIONAL(HAVE_W32CE_SYSTEM, test "$have_w32ce_system" = yes)
+AM_CONDITIONAL(CROSS_COMPILING, test x$cross_compiling = xyes)
+
+AC_DEFINE_UNQUOTED(HOST_TRIPLET_STRING, "$host", [The host triplet])
 
 
 #
diff --git a/src/Makefile.am b/src/Makefile.am
index 9ced1e5..77ece16 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -39,6 +39,11 @@ else
 noinst_PROGRAMS = gen-posix-lock-obj
 endif
 
+# Distributed lock object definitions for cross compilation.
+lock_obj_pub = \
+	syscfg/lock-obj-pub.mingw32.h
+
+
 lib_LTLIBRARIES = libgpg-error.la
 include_HEADERS = gpg-error.h
 bin_SCRIPTS = gpg-error-config
@@ -51,7 +56,7 @@ EXTRA_DIST = mkstrtable.awk err-sources.h.in err-codes.h.in \
 	mkheader.c gpg-error.h.in mkw32errmap.c w32-add.h w32ce-add.h \
 	err-sources.h err-codes.h gpg-error-config.in gpg-error.m4 \
 	gpg-error.def.in versioninfo.rc.in \
-	w32-lock-obj-pub.in
+	$(lock_obj_pub)
 
 BUILT_SOURCES = err-sources.h err-codes.h code-to-errno.h code-from-errno.h \
 	err-sources-sym.h err-codes-sym.h errnos-sym.h gpg-error.h \
@@ -62,7 +67,7 @@ tmp_files = _mkerrcodes.h _gpg-error.def.h mkw32errmap.tab.h mkw32errmap.map.c
 CLEANFILES = err-sources.h err-codes.h code-to-errno.h code-from-errno.h \
 	gpg-error.h mkerrcodes mkerrcodes.h gpg-error.def mkw32errmap.tab.h \
 	mkw32errmap.map.c err-sources-sym.h err-codes-sym.h errnos-sym.h \
-	gpg-extra/errno.h mkheader $(tmp_files) posix-lock-obj-pub.in
+	gpg-extra/errno.h mkheader $(tmp_files) lock-obj-pub.native.h
 
 if HAVE_W32_SYSTEM
 arch_sources = w32-gettext.c w32-lock.c w32-lock-obj.h w32-thread.c
@@ -106,20 +111,6 @@ libgpg_error_la_LDFLAGS = -version-info \
   @LIBGPG_ERROR_LT_CURRENT@:@LIBGPG_ERROR_LT_REVISION@:@LIBGPG_ERROR_LT_AGE@ \
   $(no_undefined) $(export_symbols)
 
-parts_of_gpg_error_h = 	 	\
-	gpg-error.h.in  	\
-	err-sources.h.in 	\
-	err-codes.h.in 	 	\
-	errnos.in 	 	\
-	w32-add.h	 	\
-	w32ce-add.h      	\
-	w32-lock-obj-pub.in
-
-if ! HAVE_W32_SYSTEM
-parts_of_gpg_error_h += posix-lock-obj-pub.in
-endif
-
-
 libgpg_error_la_SOURCES = gpg-error.h gettext.h $(arch_sources) \
 	init.c init.h version.c lock.h thread.h \
 	strsource.c strerror.c code-to-errno.c code-from-errno.c
@@ -212,14 +203,32 @@ errnos-sym.h: Makefile mkstrtable.awk errnos.in
 mkheader: mkheader.c Makefile
 	$(CC_FOR_BUILD) -g -O0 -I. -I$(srcdir) -o $@ $(srcdir)/mkheader.c
 
+parts_of_gpg_error_h = 	 	\
+	gpg-error.h.in  	\
+	err-sources.h.in 	\
+	err-codes.h.in 	 	\
+	errnos.in 	 	\
+	w32-add.h	 	\
+	w32ce-add.h      	\
+	$(lock_obj_pub)
 
-posix-lock-obj-pub.in: Makefile gen-posix-lock-obj posix-lock-obj.h
+# If we are cross-compiling we better make sure that no stale native
+# lock include file will be found by mkheader.
+if CROSS_COMPILING
+pre_mkheader_cmds = -rm lock-obj-pub.native.h 2>/dev/null
+else
+pre_mkheader_cmds = :
+parts_of_gpg_error_h += ./lock-obj-pub.native.h
+
+lock-obj-pub.native.h: Makefile gen-posix-lock-obj posix-lock-obj.h
 	./gen-posix-lock-obj >$@
+endif
 
 # We also depend on versioninfo.rc because that is build by
 # config.status and thus has up-to-date version numbers.
 gpg-error.h: Makefile mkheader $(parts_of_gpg_error_h) versioninfo.rc
-	./mkheader $(host_os) $(srcdir)/gpg-error.h.in \
+	$(pre_mkheader_cmds)
+	./mkheader $(host_os) $(host_triplet)  $(srcdir)/gpg-error.h.in \
                    $(PACKAGE_VERSION) $(VERSION_NUMBER) >$@
 
 
diff --git a/src/gen-posix-lock-obj.c b/src/gen-posix-lock-obj.c
index b641fd0..5dbc6c6 100644
--- a/src/gen-posix-lock-obj.c
+++ b/src/gen-posix-lock-obj.c
@@ -27,6 +27,7 @@
 
 #include <stdlib.h>
 #include <stdio.h>
+#include <errno.h>
 #include <pthread.h>
 
 #include "posix-lock-obj.h"
@@ -65,7 +66,8 @@ main (void)
 
   /* To force a probably suitable alignment of the structure we use a
      union and include a long and a pointer to a long.  */
-  printf ("## File created by " PGM " - DO NOT EDIT\n"
+  printf ("## lock-obj.%s.h\n"
+          "## File created by " PGM " - DO NOT EDIT\n"
           "## To be included by mkheader into gpg-error.h\n"
           "\n"
           "typedef union\n"
@@ -79,6 +81,7 @@ main (void)
           "} gpgrt_lock_t;\n"
           "\n"
           "#define GPGRT_LOCK_INITIALIZER {{{",
+          HOST_TRIPLET_STRING,
           SIZEOF_PTHREAD_MUTEX_T);
   p = (unsigned char *)&mtx;
   for (i=0; i < sizeof mtx; i++)
@@ -90,6 +93,18 @@ main (void)
         putchar (',');
     }
   printf ("},%d}}\n", LOCK_ABI_VERSION);
+  fputs ("##\n"
+         "## Loc" "al Variables:\n"
+         "## mode: c\n"
+         "## buffer-read-only: t\n"
+         "## End:\n"
+         "##\n", stdout);
+
+  if (ferror (stdout))
+    {
+      fprintf (stderr, PGM ": error writing to stdout: %s\n", strerror (errno));
+      return 1;
+    }
 
   return 0;
 }
diff --git a/src/mkheader.c b/src/mkheader.c
index e7db729..43e7fd8 100644
--- a/src/mkheader.c
+++ b/src/mkheader.c
@@ -16,12 +16,14 @@
 #include <stdlib.h>
 #include <string.h>
 #include <errno.h>
+#include <unistd.h>
 
 #define PGM "mkheader"
 
 #define LINESIZE 1024
 
 static const char *host_os;
+static const char *host_triplet;
 static char *srcdir;
 static const char *hdr_version;
 static const char *hdr_version_number;
@@ -128,6 +130,45 @@ write_errnos_in (char *line)
 }
 
 
+/* Create the full file name for NAME and return a newly allocated
+   string with it.  If name contains a '&' and REPL is not NULL
+   replace '&' with REPL. */
+static char *
+mk_include_name (const char *name, const char *repl)
+{
+  FILE *fp;
+  char *incfname, *p;
+  const char *s;
+
+  incfname = malloc (strlen (srcdir) + strlen (name)
+                     + (repl?strlen (repl):0) + 1);
+  if (!incfname)
+    {
+      fputs (PGM ": out of core\n", stderr);
+      exit (1);
+    }
+
+  if (*name == '.' && name[1] == '/')
+    *incfname = 0;
+  else
+    strcpy (incfname, srcdir);
+  p = incfname + strlen (incfname);
+  for (s=name; *s; s++)
+    {
+      if (*s == '&' && repl)
+        {
+          while (*repl)
+            *p++ = *repl++;
+          repl = NULL;  /* Replace only once.  */
+        }
+      else
+        *p++ = *s;
+    }
+  *p = 0;
+  return incfname;
+}
+
+
 /* Include the file NAME from the source directory.  The included file
    is not further expanded.  It may have comments indicated by a
    double hash mark at the begin of a line.  OUTF is called for each
@@ -141,21 +182,18 @@ include_file (const char *fname, int lnr, const char *name, void (*outf)(char*))
   char *incfname;
   int inclnr;
   char line[LINESIZE];
+  int repl_flag;
 
-  incfname = malloc (strlen (srcdir) + strlen (name) + 1);
-  if (!incfname)
+  repl_flag = !!strchr (name, '&');
+  incfname = mk_include_name (name, repl_flag? host_triplet : NULL);
+  fp = fopen (incfname, "r");
+  if (!fp && repl_flag)
     {
-      fputs (PGM ": out of core\n", stderr);
-      exit (1);
+      /* Try again using the OS string.  */
+      free (incfname);
+      incfname = mk_include_name (name, host_os);
+      fp = fopen (incfname, "r");
     }
-
-  if (*name == '.' && name[1] == '/')
-    *incfname = 0;
-  else
-    strcpy (incfname, srcdir);
-  strcat (incfname, name);
-
-  fp = fopen (incfname, "r");
   if (!fp)
     {
       fprintf (stderr, "%s:%d: error including `%s': %s\n",
@@ -163,6 +201,10 @@ include_file (const char *fname, int lnr, const char *name, void (*outf)(char*))
       exit (1);
     }
 
+  if (repl_flag)
+    fprintf (stderr,"%s:%d: note: including '%s'\n",
+             fname, lnr, incfname);
+
   inclnr = 0;
   while (fgets (line, LINESIZE, fp))
     {
@@ -206,6 +248,33 @@ include_file (const char *fname, int lnr, const char *name, void (*outf)(char*))
 }
 
 
+/* Try to include the file NAME.  Returns true if it does not
+   exist. */
+static int
+try_include_file (const char *fname, int lnr, const char *name,
+                  void (*outf)(char*))
+{
+  int rc;
+  char *incfname;
+  int repl_flag;
+
+  repl_flag = !!strchr (name, '&');
+  incfname = mk_include_name (name, repl_flag? host_triplet : NULL);
+  rc = access (incfname, R_OK);
+  if (rc && repl_flag)
+    {
+      free (incfname);
+      incfname = mk_include_name (name, host_os);
+      rc = access (incfname, R_OK);
+    }
+  if (!rc)
+    include_file (fname, lnr, name, outf);
+
+  free (incfname);
+  return rc;
+}
+
+
 static int
 write_special (const char *fname, int lnr, const char *tag)
 {
@@ -249,12 +318,8 @@ write_special (const char *fname, int lnr, const char *tag)
     }
   else if (!strcmp (tag, "include:lock-obj"))
     {
-      if (!strcmp (host_os, "mingw32"))
-        {
-          include_file (fname, lnr, "w32-lock-obj-pub.in", write_line);
-        }
-      else
-        include_file (fname, lnr, "./posix-lock-obj-pub.in", write_line);
+      if (try_include_file (fname, lnr, "./lock-obj-pub.native.h", write_line))
+        include_file (fname, lnr, "syscfg/lock-obj-pub.&.h", write_line);
     }
   else
     return 0; /* Unknown tag.  */
@@ -277,16 +342,18 @@ main (int argc, char **argv)
       argc--; argv++;
     }
 
-  if (argc != 4)
+  if (argc != 5)
     {
-      fputs ("usage: " PGM " host_os template.h version version_number\n",
+      fputs ("usage: " PGM
+             " host_os host_triplet template.h version version_number\n",
              stderr);
       return 1;
     }
   host_os = argv[0];
-  fname = argv[1];
-  hdr_version = argv[2];
-  hdr_version_number = argv[3];
+  host_triplet = argv[1];
+  fname = argv[2];
+  hdr_version = argv[3];
+  hdr_version_number = argv[4];
 
   srcdir = malloc (strlen (fname) + 2 + 1);
   if (!srcdir)
@@ -337,8 +404,8 @@ main (int argc, char **argv)
       if (!strcmp (p1, "configure_input"))
         {
           s = strrchr (fname, '/');
-          printf ("Do not edit.  Generated from %s by %s for %s.",
-                  s? s+1 : fname, PGM, host_os);
+          printf ("Do not edit.  Generated from %s for %s.",
+                  s? s+1 : fname, host_triplet);
           fputs (p2, stdout);
           putchar ('\n');
         }
diff --git a/src/w32-lock-obj-pub.in b/src/syscfg/lock-obj-pub.mingw32.h
similarity index 100%
rename from src/w32-lock-obj-pub.in
rename to src/syscfg/lock-obj-pub.mingw32.h

-----------------------------------------------------------------------

Summary of changes:
 README                                             |   24 ++++
 configure.ac                                       |    3 +
 src/Makefile.am                                    |   45 +++++---
 src/gen-posix-lock-obj.c                           |   38 +++++--
 src/mkheader.c                                     |  117 +++++++++++++++-----
 src/posix-lock-obj.h                               |    5 +-
 src/posix-lock.c                                   |    8 +-
 .../lock-obj-pub.mingw32.h}                        |    0
 8 files changed, 181 insertions(+), 59 deletions(-)
 rename src/{w32-lock-obj-pub.in => syscfg/lock-obj-pub.mingw32.h} (100%)


hooks/post-receive
-- 
Error codes used by GnuPG et al.
http://git.gnupg.org




More information about the Gnupg-commits mailing list