Skip to content

Commit

Permalink
build BUGFIX fix BSD builds, again, and cleanup
Browse files Browse the repository at this point in the history
- just define _GNU_SOURCE and include sys/cdefs.h this gets everything
set the right way (no need to define _POSIX_C_SOURCE, etc).
- BSD requires more includes to get to sockaddr and AF_*
  • Loading branch information
choppsv1 committed May 1, 2021
1 parent 6b669ff commit 0e8a329
Show file tree
Hide file tree
Showing 12 changed files with 32 additions and 26 deletions.
5 changes: 2 additions & 3 deletions src/context.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@
*
* https://opensource.org/licenses/BSD-3-Clause
*/
#define _GNU_SOURCE /* asprintf */
#define _POSIX_C_SOURCE 200809L /* strdup */

#define _GNU_SOURCE /* asprintf, strdup */
#if defined (__NetBSD__) || defined (__OpenBSD__)
/* realpath */
#define _XOPEN_SOURCE 1
#define _XOPEN_SOURCE_EXTENDED 1
#endif
#include <sys/cdefs.h>

#include "context.h"

Expand Down
4 changes: 2 additions & 2 deletions src/diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
*
* https://opensource.org/licenses/BSD-3-Clause
*/
#define _POSIX_C_SOURCE 200809L /* strdup */
#define _GNU_SOURCE /* asprintf */
#define _GNU_SOURCE /* asprintf, strdup */
#include <sys/cdefs.h>

#include "diff.h"

Expand Down
4 changes: 2 additions & 2 deletions src/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
* https://opensource.org/licenses/BSD-3-Clause
*/

#define _GNU_SOURCE
#define _POSIX_C_SOURCE 200809L /* strdup */
#define _GNU_SOURCE /* asprintf, strdup */
#include <sys/cdefs.h>

#include "log.h"

Expand Down
4 changes: 2 additions & 2 deletions src/out.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
* https://opensource.org/licenses/BSD-3-Clause
*/

#define _GNU_SOURCE
#define _POSIX_C_SOURCE 200809L /* strdup, vdprintf */
#define _GNU_SOURCE /* asprintf, strdup */
#include <sys/cdefs.h>

#include "out.h"
#include "out_internal.h"
Expand Down
4 changes: 2 additions & 2 deletions src/plugins_types.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
* https://opensource.org/licenses/BSD-3-Clause
*/

#define _GNU_SOURCE
#define _POSIX_C_SOURCE 200809L /* strdup */
#define _GNU_SOURCE /* asprintf, strdup */
#include <sys/cdefs.h>

#include "plugins_types.h"

Expand Down
7 changes: 6 additions & 1 deletion src/plugins_types/ip_prefix.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,16 @@
* https://opensource.org/licenses/BSD-3-Clause
*/

#define _GNU_SOURCE
#define _GNU_SOURCE /* asprintf, strdup */
#include <sys/cdefs.h>

#include "plugins_types.h"

#include <arpa/inet.h>
#if defined (__FreeBSD__) || defined (__NetBSD__) || defined (__OpenBSD__)
#include <netinet/in.h>
#include <sys/socket.h>
#endif
#include <assert.h>
#include <errno.h>
#include <stdint.h>
Expand Down
7 changes: 6 additions & 1 deletion src/plugins_types/ipv6_address.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,16 @@
* https://opensource.org/licenses/BSD-3-Clause
*/

#define _GNU_SOURCE
#define _GNU_SOURCE /* asprintf, strdup */
#include <sys/cdefs.h>

#include "plugins_types.h"

#include <arpa/inet.h>
#if defined (__FreeBSD__) || defined (__NetBSD__) || defined (__OpenBSD__)
#include <netinet/in.h>
#include <sys/socket.h>
#endif
#include <assert.h>
#include <ctype.h>
#include <errno.h>
Expand Down
4 changes: 2 additions & 2 deletions src/schema_compile_node.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
* https://opensource.org/licenses/BSD-3-Clause
*/

#define _GNU_SOURCE
#define _POSIX_C_SOURCE 200809L /* strdup, strndup */
#define _GNU_SOURCE /* asprintf, strdup */
#include <sys/cdefs.h>

#include "schema_compile_node.h"

Expand Down
4 changes: 2 additions & 2 deletions src/tree_schema.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
* https://opensource.org/licenses/BSD-3-Clause
*/

#define _GNU_SOURCE
#define _POSIX_C_SOURCE 200809L /* strdup */
#define _GNU_SOURCE /* asprintf, strdup */
#include <sys/cdefs.h>

#include "tree_schema.h"

Expand Down
4 changes: 2 additions & 2 deletions src/validation.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
*
* https://opensource.org/licenses/BSD-3-Clause
*/
#define _POSIX_C_SOURCE 200809L /* strdup */
#define _GNU_SOURCE /* asprintf */
#define _GNU_SOURCE /* asprintf, strdup */
#include <sys/cdefs.h>

#include "validation.h"

Expand Down
7 changes: 2 additions & 5 deletions src/xpath.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@
*
* https://opensource.org/licenses/BSD-3-Clause
*/
#define _GNU_SOURCE
#define _POSIX_C_SOURCE 200809L /* strdup, strndup */

/* needed by libmath functions isfinite(), isinf(), isnan(), signbit(), ... */
#define _ISOC99_SOURCE
#define _GNU_SOURCE /* asprintf, strdup */
#include <sys/cdefs.h>

#include "xpath.h"

Expand Down
4 changes: 2 additions & 2 deletions tools/re/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
* https://opensource.org/licenses/BSD-3-Clause
*/

#define _GNU_SOURCE
#define _POSIX_C_SOURCE 200809L /* strdup, getline */
#define _GNU_SOURCE /* asprintf, strdup */
#include <sys/cdefs.h>

#include <errno.h>
#include <getopt.h>
Expand Down

0 comments on commit 0e8a329

Please sign in to comment.