From 95e2455cdbf840bdcf913f4ef59d0109babd3d6a Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 24 Jan 2012 16:08:00 -0500 Subject: [PATCH] When including an -internal.h header outside the main tree, do so early Some of our unit tests and sample code need functions and structures defined in an -internal.h header. But that can freak out OpenSolaris, where stdio.h wants to define _FILE_OFFSET_BITS unless it's already defined, and then evconfig-internal.h defines it. Regular users should never ever use our -internal.h headers, so the solution is to make sure that if we're going to use them ourselves, we do so before system headers. --- sample/http-server.c | 6 +++--- test/bench_httpclient.c | 6 +++--- test/regress.c | 2 +- test/regress_buffer.c | 2 +- test/regress_bufferevent.c | 1 + test/regress_dns.c | 3 +-- test/regress_http.c | 2 +- test/regress_listener.c | 2 +- test/regress_main.c | 1 + test/regress_minheap.c | 2 +- test/regress_testutils.c | 3 +-- test/regress_thread.c | 4 ++-- test/regress_util.c | 3 ++- test/test-ratelim.c | 2 +- test/tinytest.c | 7 +++---- test/tinytest_local.h | 2 +- 16 files changed, 24 insertions(+), 24 deletions(-) diff --git a/sample/http-server.c b/sample/http-server.c index d8cde609..2d04fd30 100644 --- a/sample/http-server.c +++ b/sample/http-server.c @@ -6,6 +6,9 @@ */ +/* Compatibility for possible missing IPv6 declarations */ +#include "../util-internal.h" + #include #include #include @@ -44,9 +47,6 @@ # endif #endif -/* Compatibility for possible missing IPv6 declarations */ -#include "../util-internal.h" - #ifdef _WIN32 #define stat _stat #define fstat _fstat diff --git a/test/bench_httpclient.c b/test/bench_httpclient.c index ce5c16a3..c37d1cb3 100644 --- a/test/bench_httpclient.c +++ b/test/bench_httpclient.c @@ -25,6 +25,9 @@ * */ +/* for EVUTIL_ERR_CONNECT_RETRIABLE macro */ +#include "util-internal.h" + #include #ifdef _WIN32 #include @@ -44,9 +47,6 @@ #include "event2/buffer.h" #include "event2/util.h" -/* for EVUTIL_ERR_CONNECT_RETRIABLE macro */ -#include "util-internal.h" - const char *resource = NULL; struct event_base *base = NULL; diff --git a/test/regress.c b/test/regress.c index bed29b1a..d3435694 100644 --- a/test/regress.c +++ b/test/regress.c @@ -24,6 +24,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include "util-internal.h" #ifdef _WIN32 #include @@ -63,7 +64,6 @@ #include "event2/util.h" #include "event-internal.h" #include "evthread-internal.h" -#include "util-internal.h" #include "log-internal.h" #include "regress.h" diff --git a/test/regress_buffer.c b/test/regress_buffer.c index ba9a1854..6348a235 100644 --- a/test/regress_buffer.c +++ b/test/regress_buffer.c @@ -24,6 +24,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include "util-internal.h" #ifdef _WIN32 #include @@ -58,7 +59,6 @@ #include "evbuffer-internal.h" #include "log-internal.h" -#include "util-internal.h" #include "regress.h" diff --git a/test/regress_bufferevent.c b/test/regress_bufferevent.c index 82d582cd..dd5097ad 100644 --- a/test/regress_bufferevent.c +++ b/test/regress_bufferevent.c @@ -24,6 +24,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include "util-internal.h" /* The old tests here need assertions to work. */ #undef NDEBUG diff --git a/test/regress_dns.c b/test/regress_dns.c index 9c24061c..1c8bf59f 100644 --- a/test/regress_dns.c +++ b/test/regress_dns.c @@ -24,6 +24,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include "../util-internal.h" #ifdef _WIN32 #include @@ -71,8 +72,6 @@ #include "regress.h" #include "regress_testutils.h" -#include "../util-internal.h" - static int dns_ok = 0; static int dns_got_cancel = 0; static int dns_err = 0; diff --git a/test/regress_http.c b/test/regress_http.c index 31eef55b..f05a0b85 100644 --- a/test/regress_http.c +++ b/test/regress_http.c @@ -24,6 +24,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include "util-internal.h" #ifdef _WIN32 #include @@ -59,7 +60,6 @@ #include "event2/bufferevent.h" #include "event2/util.h" #include "log-internal.h" -#include "util-internal.h" #include "http-internal.h" #include "regress.h" #include "regress_testutils.h" diff --git a/test/regress_listener.c b/test/regress_listener.c index f32efa27..05be110f 100644 --- a/test/regress_listener.c +++ b/test/regress_listener.c @@ -23,6 +23,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include "util-internal.h" #ifdef _WIN32 #include @@ -49,7 +50,6 @@ #include "regress.h" #include "tinytest.h" #include "tinytest_macros.h" -#include "util-internal.h" static void acceptcb(struct evconnlistener *listener, evutil_socket_t fd, diff --git a/test/regress_main.c b/test/regress_main.c index 1a0bdec5..fae958a6 100644 --- a/test/regress_main.c +++ b/test/regress_main.c @@ -24,6 +24,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include "util-internal.h" #ifdef _WIN32 #include diff --git a/test/regress_minheap.c b/test/regress_minheap.c index 7e5522f7..28e9ea6b 100644 --- a/test/regress_minheap.c +++ b/test/regress_minheap.c @@ -23,13 +23,13 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include "../minheap-internal.h" #include #include "event2/event_struct.h" #include "tinytest.h" #include "tinytest_macros.h" -#include "../minheap-internal.h" static void set_random_timeout(struct event *ev) diff --git a/test/regress_testutils.c b/test/regress_testutils.c index 45e9eb80..ecc90daf 100644 --- a/test/regress_testutils.c +++ b/test/regress_testutils.c @@ -23,6 +23,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include "../util-internal.h" #ifdef _WIN32 #include @@ -68,8 +69,6 @@ #include "regress.h" #include "regress_testutils.h" -#include "../util-internal.h" - /* globals */ static struct evdns_server_port *dns_port; evutil_socket_t dns_sock = -1; diff --git a/test/regress_thread.c b/test/regress_thread.c index aaa925d1..0c5c5be3 100644 --- a/test/regress_thread.c +++ b/test/regress_thread.c @@ -23,6 +23,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include "util-internal.h" /* The old tests here need assertions to work. */ #undef NDEBUG @@ -53,14 +54,13 @@ #include "sys/queue.h" -#include "event2/util.h" #include "event2/event.h" #include "event2/event_struct.h" #include "event2/thread.h" +#include "event2/util.h" #include "evthread-internal.h" #include "event-internal.h" #include "defer-internal.h" -#include "util-internal.h" #include "regress.h" #include "tinytest_macros.h" diff --git a/test/regress_util.c b/test/regress_util.c index 376ac8b5..3e7ba90c 100644 --- a/test/regress_util.c +++ b/test/regress_util.c @@ -23,6 +23,8 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include "../util-internal.h" + #ifdef _WIN32 #include #include @@ -53,7 +55,6 @@ #include "event2/event.h" #include "event2/util.h" #include "../ipv6-internal.h" -#include "../util-internal.h" #include "../log-internal.h" #include "../strlcpy-internal.h" #include "../mm-internal.h" diff --git a/test/test-ratelim.c b/test/test-ratelim.c index c5ba30e4..eef686a9 100644 --- a/test/test-ratelim.c +++ b/test/test-ratelim.c @@ -23,6 +23,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include "../util-internal.h" #include #include @@ -49,7 +50,6 @@ #include "event2/listener.h" #include "event2/thread.h" -#include "../util-internal.h" static int cfg_verbose = 0; static int cfg_help = 0; diff --git a/test/tinytest.c b/test/tinytest.c index d3103efe..29ea41ae 100644 --- a/test/tinytest.c +++ b/test/tinytest.c @@ -22,16 +22,15 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#ifdef TINYTEST_LOCAL +#include "tinytest_local.h" +#endif #include #include #include #include -#ifdef TINYTEST_LOCAL -#include "tinytest_local.h" -#endif - #ifdef _WIN32 #include #else diff --git a/test/tinytest_local.h b/test/tinytest_local.h index 888b1159..87ec2fa6 100644 --- a/test/tinytest_local.h +++ b/test/tinytest_local.h @@ -1,10 +1,10 @@ +#include "util-internal.h" #ifdef _WIN32 #include #endif #include "event2/util.h" -#include "util-internal.h" #ifdef snprintf #undef snprintf -- 2.49.0