Skip to content

Commit

Permalink
Merge pull request #320 from maxmind/horgh/posix
Browse files Browse the repository at this point in the history
Do not set feature test macro in public header
  • Loading branch information
oschwald authored Aug 8, 2023
2 parents 876e68c + 5771620 commit 83758e5
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 22 deletions.
5 changes: 4 additions & 1 deletion Changes.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion NOTICE
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions bin/mmdblookup.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#ifndef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 200809L
#endif

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
Expand Down
7 changes: 6 additions & 1 deletion doc/libmaxminddb.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion doc/mmdblookup.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
12 changes: 0 additions & 12 deletions include/maxminddb.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <stdarg.h>
#include <stdbool.h>
Expand Down
4 changes: 4 additions & 0 deletions src/data-pool.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#ifndef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 200809L
#endif

#include "data-pool.h"
#include "maxminddb.h"

Expand Down
4 changes: 4 additions & 0 deletions src/maxminddb.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#ifndef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 200809L
#endif

#if HAVE_CONFIG_H
#include <config.h>
#endif
Expand Down
1 change: 1 addition & 0 deletions t/dump_t.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#define _XOPEN_SOURCE 700

#include "maxminddb_test_helper.h"

#ifdef HAVE_OPEN_MEMSTREAM
Expand Down
4 changes: 2 additions & 2 deletions t/maxminddb_test_helper.c
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#include "maxminddb_test_helper.h"

#if HAVE_CONFIG_H
#include <config.h>
#endif

#define _POSIX_C_SOURCE 200112L
#include <assert.h>
#include <stdarg.h>
#include <sys/types.h>

#include "maxminddb.h"
#include "maxminddb_test_helper.h"

#ifdef _WIN32
#include <io.h>
Expand Down
8 changes: 5 additions & 3 deletions t/maxminddb_test_helper.h
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 83758e5

Please sign in to comment.