e_os.h removal from other headers and source files.

Removed e_os.h from all bar three headers (apps/apps.h crypto/bio/bio_lcl.h and
ssl/ssl_locl.h).

Added e_os.h into the files that need it now.

Directly reference internal/nelem.h when required.

Reviewed-by: Andy Polyakov <appro@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/4188)
diff --git a/ssl/d1_lib.c b/ssl/d1_lib.c
index dd62e0c..e4abe92 100644
--- a/ssl/d1_lib.c
+++ b/ssl/d1_lib.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005-2016 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2005-2017 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the OpenSSL license (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -11,6 +11,7 @@
 #include <openssl/objects.h>
 #include <openssl/rand.h>
 #include "ssl_locl.h"
+#include "e_os.h"
 
 #if defined(OPENSSL_SYS_VXWORKS)
 # include <sys/times.h>
diff --git a/ssl/record/rec_layer_s3.c b/ssl/record/rec_layer_s3.c
index d1dfb92..aec5687 100644
--- a/ssl/record/rec_layer_s3.c
+++ b/ssl/record/rec_layer_s3.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the OpenSSL license (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
diff --git a/ssl/s3_lib.c b/ssl/s3_lib.c
index fdccdb7..1a5c3f7 100644
--- a/ssl/s3_lib.c
+++ b/ssl/s3_lib.c
@@ -11,7 +11,9 @@
 
 #include <stdio.h>
 #include <openssl/objects.h>
+#include "internal/nelem.h"
 #include "ssl_locl.h"
+#include "e_os.h"
 #include <openssl/md5.h>
 #include <openssl/dh.h>
 #include <openssl/rand.h>
diff --git a/ssl/ssl_cert.c b/ssl/ssl_cert.c
index a0dd878..ad78545 100644
--- a/ssl/ssl_cert.c
+++ b/ssl/ssl_cert.c
@@ -11,7 +11,11 @@
 #include <stdio.h>
 #include <sys/types.h>
 
-#include "e_os.h"
+#include "internal/nelem.h"
+#ifndef NO_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+
 #include "internal/o_dir.h"
 #include <openssl/lhash.h>
 #include <openssl/bio.h>
@@ -20,6 +24,7 @@
 #include <openssl/dh.h>
 #include <openssl/bn.h>
 #include <openssl/crypto.h>
+#include "e_os.h"
 #include "ssl_locl.h"
 #include "ssl_cert_table.h"
 #include "internal/thread_once.h"
diff --git a/ssl/ssl_ciph.c b/ssl/ssl_ciph.c
index 60e1308..17bd939 100644
--- a/ssl/ssl_ciph.c
+++ b/ssl/ssl_ciph.c
@@ -15,6 +15,7 @@
 #include <openssl/comp.h>
 #include <openssl/engine.h>
 #include <openssl/crypto.h>
+#include "internal/nelem.h"
 #include "ssl_locl.h"
 #include "internal/thread_once.h"
 #include "internal/cryptlib.h"
diff --git a/ssl/ssl_conf.c b/ssl/ssl_conf.c
index 6dd5922..1a8dc15 100644
--- a/ssl/ssl_conf.c
+++ b/ssl/ssl_conf.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2012-2016 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2012-2017 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the OpenSSL license (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -12,6 +12,7 @@
 #include <openssl/conf.h>
 #include <openssl/objects.h>
 #include <openssl/dh.h>
+#include "internal/nelem.h"
 
 /*
  * structure holding name tables. This is used for permitted elements in lists
diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c
index 501a12c..eb8603d 100644
--- a/ssl/ssl_lib.c
+++ b/ssl/ssl_lib.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
  * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved
  * Copyright 2005 Nokia. All rights reserved.
  *
@@ -10,6 +10,7 @@
  */
 
 #include <stdio.h>
+#include "e_os.h"
 #include "ssl_locl.h"
 #include <openssl/objects.h>
 #include <openssl/lhash.h>
diff --git a/ssl/ssl_locl.h b/ssl/ssl_locl.h
index f14148a..72f4875 100644
--- a/ssl/ssl_locl.h
+++ b/ssl/ssl_locl.h
@@ -16,7 +16,7 @@
 # include <string.h>
 # include <errno.h>
 
-# include "e_os.h"
+# include "e_os.h"              /* struct timeval for Windows */
 # if defined(__unix) || defined(__unix__)
 #  include <sys/time.h>         /* struct timeval for DTLS */
 # endif
diff --git a/ssl/ssl_sess.c b/ssl/ssl_sess.c
index efba707..ea5309e 100644
--- a/ssl/ssl_sess.c
+++ b/ssl/ssl_sess.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
  * Copyright 2005 Nokia. All rights reserved.
  *
  * Licensed under the OpenSSL license (the "License").  You may not use
@@ -12,6 +12,7 @@
 #include <openssl/lhash.h>
 #include <openssl/rand.h>
 #include <openssl/engine.h>
+#include "e_os.h"
 #include "ssl_locl.h"
 #include "statem/statem_locl.h"
 
diff --git a/ssl/statem/extensions.c b/ssl/statem/extensions.c
index d569f6c..c435405 100644
--- a/ssl/statem/extensions.c
+++ b/ssl/statem/extensions.c
@@ -8,6 +8,7 @@
  */
 
 #include <string.h>
+#include "internal/nelem.h"
 #include "../ssl_locl.h"
 #include "statem_locl.h"
 
diff --git a/ssl/statem/statem.c b/ssl/statem/statem.c
index 4f259fd..fd48f66 100644
--- a/ssl/statem/statem.c
+++ b/ssl/statem/statem.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2015-2017 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the OpenSSL license (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -8,6 +8,7 @@
  */
 
 #include <openssl/rand.h>
+#include "e_os.h"
 #include "../ssl_locl.h"
 #include "statem_locl.h"
 
diff --git a/ssl/t1_lib.c b/ssl/t1_lib.c
index 02ed680..48c33de 100644
--- a/ssl/t1_lib.c
+++ b/ssl/t1_lib.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the OpenSSL license (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -17,6 +17,7 @@
 #include <openssl/x509v3.h>
 #include <openssl/dh.h>
 #include <openssl/bn.h>
+#include "internal/nelem.h"
 #include "ssl_locl.h"
 #include <openssl/ct.h>