Merge "Rewrite <fenv.h> for ARM."
diff --git a/libc/tools/zoneinfo/generate b/libc/tools/zoneinfo/generate
index 27d023f..ba8ea0d 100755
--- a/libc/tools/zoneinfo/generate
+++ b/libc/tools/zoneinfo/generate
@@ -32,22 +32,22 @@
 
 
 def GetCurrentTzDataVersion():
-  return open('%s/tzdata' % bionic_libc_zoneinfo_dir).read().split('\0', 1)[0]
+  return open('%s/tzdata' % bionic_libc_zoneinfo_dir).read().split('\x00', 1)[0]
 
 
 def WriteSetupFile():
+  """Writes the list of zones that ZoneCompactor should process."""
   links = []
   zones = []
   for region in regions:
     for line in open('extracted/%s' % region):
       fields = line.split()
-      if len(fields) == 0:
-        continue
-      elif fields[0] == 'Link':
-        links.append('%s %s %s\n' % (fields[0], fields[1], fields[2]))
-        zones.append(fields[2])
-      elif fields[0] == 'Zone':
-        zones.append(fields[1])
+      if fields:
+        if fields[0] == 'Link':
+          links.append('%s %s %s\n' % (fields[0], fields[1], fields[2]))
+          zones.append(fields[2])
+        elif fields[0] == 'Zone':
+          zones.append(fields[1])
   zones.sort()
 
   setup = open('setup', 'w')
@@ -58,20 +58,34 @@
   setup.close()
 
 
-def UpgradeTo(ftp, filename):
-  new_version = re.search('(tzdata.+)\.tar\.gz', filename).group(1)
+def Retrieve(ftp, filename):
+  ftp.retrbinary('RETR %s' % filename, open(filename, 'wb').write)
+
+
+def UpgradeTo(ftp, data_filename):
+  """Downloads and repackages the given data from the given FTP server."""
+
+  new_version = re.search('(tzdata.+)\\.tar\\.gz', data_filename).group(1)
+  signature_filename = '%s.sign' % data_filename
 
   # Switch to a temporary directory.
   tmp_dir = tempfile.mkdtemp('-tzdata')
   os.chdir(tmp_dir)
   print 'Created temporary directory "%s"...' % tmp_dir
 
-  print 'Downloading...'
-  ftp.retrbinary('RETR %s' % filename, open(filename, 'wb').write)
+  print 'Downloading data and signature...'
+  Retrieve(ftp, data_filename)
+  Retrieve(ftp, signature_filename)
+
+  print 'Verifying signature...'
+  # If this fails for you, you probably need to import Paul Eggert's public key:
+  # gpg --recv-keys ED97E90E62AA7E34
+  subprocess.check_call(['gpg', '--trusted-key=ED97E90E62AA7E34',
+                         '--verify', signature_filename, data_filename])
 
   print 'Extracting...'
   os.mkdir('extracted')
-  tar = tarfile.open(filename, 'r')
+  tar = tarfile.open(data_filename, 'r')
   tar.extractall('extracted')
 
   print 'Calling zic(1)...'
@@ -94,17 +108,15 @@
 
 
 # Run with no arguments from any directory, with no special setup required.
+# See http://www.iana.org/time-zones/ for more about the source of this data.
 def main():
-  # URL from "Sources for Time Zone and Daylight Saving Time Data"
-  # http://www.twinsun.com/tz/tz-link.htm
-
   print 'Looking for new tzdata...'
   ftp = ftplib.FTP('ftp.iana.org')
   ftp.login()
   ftp.cwd('tz/releases')
   tzdata_filenames = []
   for filename in ftp.nlst():
-    if filename.startswith('tzdata20'):
+    if filename.startswith('tzdata20') and filename.endswith('.tar.gz'):
       tzdata_filenames.append(filename)
   tzdata_filenames.sort()
 
diff --git a/libc/zoneinfo/tzdata b/libc/zoneinfo/tzdata
index 272b18c..367c0f9 100644
--- a/libc/zoneinfo/tzdata
+++ b/libc/zoneinfo/tzdata
Binary files differ
diff --git a/linker/linker.cpp b/linker/linker.cpp
index 4d2e72f..409580e 100755
--- a/linker/linker.cpp
+++ b/linker/linker.cpp
@@ -160,7 +160,8 @@
 #define DL_ERR(fmt, x...) \
     do { \
         format_buffer(__linker_dl_err_buf, sizeof(__linker_dl_err_buf), fmt, ##x); \
-        ERROR(fmt "\n", ##x); \
+        /* If LD_DEBUG is set high enough, send every dlerror(3) message to the log. */ \
+        DEBUG(fmt "\n", ##x); \
     } while(0)
 
 const char* linker_get_error() {
@@ -644,7 +645,7 @@
   for (size_t i = 0; paths[i] != NULL; ++i) {
     int n = format_buffer(buf, sizeof(buf), "%s/%s", paths[i], name);
     if (n < 0 || n >= static_cast<int>(sizeof(buf))) {
-      WARN("Ignoring very long library path: %s/%s\n", paths[i], name);
+      PRINT("Warning: ignoring very long library path: %s/%s\n", paths[i], name);
       continue;
     }
     int fd = TEMP_FAILURE_RETRY(open(buf, O_RDONLY | O_CLOEXEC));
@@ -960,7 +961,7 @@
     si->refcount = 0;
   } else {
     si->refcount--;
-    PRINT("not unloading '%s', decrementing refcount to %d\n", si->name, si->refcount);
+    TRACE("not unloading '%s', decrementing refcount to %d\n", si->name, si->refcount);
   }
   return 0;
 }
diff --git a/linker/linker_debug.h b/linker/linker_debug.h
index c1df1dd..0a3710b 100644
--- a/linker/linker_debug.h
+++ b/linker/linker_debug.h
@@ -71,8 +71,6 @@
 #define PRINT(x...)          _PRINTVF(-1, x)
 #define INFO(x...)           _PRINTVF(0, x)
 #define TRACE(x...)          _PRINTVF(1, x)
-#define WARN(fmt,args...)    _PRINTVF(-1, "%s:%d| WARNING: " fmt, __FILE__, __LINE__, ## args)
-#define ERROR(fmt,args...)   _PRINTVF(-1, "%s:%d| ERROR: " fmt, __FILE__, __LINE__, ## args)
 
 #if TRACE_DEBUG
 #define DEBUG(x...)          _PRINTVF(2, "DEBUG: " x)
@@ -82,9 +80,4 @@
 
 #define TRACE_TYPE(t,x...)   do { if (DO_TRACE_##t) { TRACE(x); } } while (0)
 
-#if TIMING
-#undef WARN
-#define WARN(x...)           do {} while (0)
-#endif /* TIMING */
-
 #endif /* _LINKER_DEBUG_H_ */