diff --git a/Changes.md b/Changes.md index 384e7b0e..d0cd76ca 100644 --- a/Changes.md +++ b/Changes.md @@ -1,7 +1,10 @@ -## 1.7.2 +## 1.8.0 * `PACKAGE_VERSION` is now a private compile definition when building with CMake. Pull request by bsergean. GitHub #308. +* The feature test macro `_POSIX_C_SOURCE` is no longer set by + `maxminddb.h`. As discussed in GitHub #318, this should be set by + applications rather than by libraries. ## 1.7.1 - 2022-09-30 diff --git a/NOTICE b/NOTICE index 7a695dee..dba215ea 100644 --- a/NOTICE +++ b/NOTICE @@ -1,4 +1,4 @@ -Copyright 2013-2022 MaxMind, Inc. +Copyright 2013-2023 MaxMind, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/README.md b/README.md index 2a4df66a..0a4949b9 100644 --- a/README.md +++ b/README.md @@ -110,6 +110,11 @@ Or with [MacPorts](https://ports.macports.org/port/libmaxminddb): $ sudo port install libmaxminddb +# Requirements + +libmaxminddb requires a minimum of POSIX.1-2001 support. If not specified +at compilation time, it defaults to requesting POSIX.1-2008 support. + # Bug Reports Please report bugs by filing an issue with our GitHub issue tracker at @@ -121,7 +126,7 @@ Use `make safedist` to check the resulting tarball. # Copyright and License -Copyright 2013-2022 MaxMind, Inc. +Copyright 2013-2023 MaxMind, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/bin/mmdblookup.c b/bin/mmdblookup.c index 1989c57b..3652cd51 100644 --- a/bin/mmdblookup.c +++ b/bin/mmdblookup.c @@ -1,3 +1,7 @@ +#ifndef _POSIX_C_SOURCE +#define _POSIX_C_SOURCE 200809L +#endif + #ifdef HAVE_CONFIG_H #include #endif diff --git a/doc/libmaxminddb.md b/doc/libmaxminddb.md index 431d8054..48ac06a0 100644 --- a/doc/libmaxminddb.md +++ b/doc/libmaxminddb.md @@ -851,6 +851,11 @@ int main(int argc, char **argv) } ``` +# REQUIREMENTS + +libmaxminddb requires a minimum of POSIX.1-2001 support. If not specified +at compilation time, it defaults to requesting POSIX.1-2008 support. + # THREAD SAFETY This library is thread safe when compiled and linked with a thread-safe @@ -878,7 +883,7 @@ Rolsky (drolsky@maxmind.com). # COPYRIGHT AND LICENSE -Copyright 2013-2022 MaxMind, Inc. +Copyright 2013-2023 MaxMind, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/doc/mmdblookup.md b/doc/mmdblookup.md index 6278d11a..47946310 100644 --- a/doc/mmdblookup.md +++ b/doc/mmdblookup.md @@ -84,7 +84,7 @@ Rolsky (drolsky@maxmind.com). # COPYRIGHT AND LICENSE -Copyright 2013-2022 MaxMind, Inc. +Copyright 2013-2023 MaxMind, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/maxminddb.h b/include/maxminddb.h index 028aa214..980abf99 100644 --- a/include/maxminddb.h +++ b/include/maxminddb.h @@ -5,18 +5,6 @@ extern "C" { #ifndef MAXMINDDB_H #define MAXMINDDB_H -/* Request POSIX.1-2008. However, we want to remain compatible with - * POSIX.1-2001 (since we have been historically and see no reason to drop - * compatibility). By requesting POSIX.1-2008, we can conditionally use - * features provided by that standard if the implementation provides it. We can - * check for what the implementation provides by checking the _POSIX_VERSION - * macro after including unistd.h. If a feature is in POSIX.1-2008 but not - * POSIX.1-2001, check that macro before using the feature (or check for the - * feature directly if possible). */ -#ifndef _POSIX_C_SOURCE -#define _POSIX_C_SOURCE 200809L -#endif - #include "maxminddb_config.h" #include #include diff --git a/src/data-pool.c b/src/data-pool.c index 7b3c2a59..7d47ddff 100644 --- a/src/data-pool.c +++ b/src/data-pool.c @@ -1,3 +1,7 @@ +#ifndef _POSIX_C_SOURCE +#define _POSIX_C_SOURCE 200809L +#endif + #include "data-pool.h" #include "maxminddb.h" diff --git a/src/maxminddb.c b/src/maxminddb.c index 7da1d340..c965c2a3 100644 --- a/src/maxminddb.c +++ b/src/maxminddb.c @@ -1,3 +1,7 @@ +#ifndef _POSIX_C_SOURCE +#define _POSIX_C_SOURCE 200809L +#endif + #if HAVE_CONFIG_H #include #endif diff --git a/t/dump_t.c b/t/dump_t.c index dae32ef8..2c817d03 100644 --- a/t/dump_t.c +++ b/t/dump_t.c @@ -1,4 +1,5 @@ #define _XOPEN_SOURCE 700 + #include "maxminddb_test_helper.h" #ifdef HAVE_OPEN_MEMSTREAM diff --git a/t/maxminddb_test_helper.c b/t/maxminddb_test_helper.c index 7272c151..545cdc0c 100644 --- a/t/maxminddb_test_helper.c +++ b/t/maxminddb_test_helper.c @@ -1,14 +1,14 @@ +#include "maxminddb_test_helper.h" + #if HAVE_CONFIG_H #include #endif -#define _POSIX_C_SOURCE 200112L #include #include #include #include "maxminddb.h" -#include "maxminddb_test_helper.h" #ifdef _WIN32 #include diff --git a/t/maxminddb_test_helper.h b/t/maxminddb_test_helper.h index a782daa1..b037f955 100644 --- a/t/maxminddb_test_helper.h +++ b/t/maxminddb_test_helper.h @@ -1,6 +1,8 @@ -/* Some test files may require something newer */ -#if !defined(_GNU_SOURCE) && !defined(_POSIX_C_SOURCE) -#define _POSIX_C_SOURCE 200112L +// The spec says this should be set prior to including any headers, but since +// this is test code, it should be fine to set it here. Setting it here avoids +// setting it in every test program. +#ifndef _POSIX_C_SOURCE +#define _POSIX_C_SOURCE 200809L #endif #if HAVE_CONFIG_H