Skip to content

Commit

Permalink
Platform-specific includes for macOS and non-macOS systems
Browse files Browse the repository at this point in the history
Removed the unnecessary `PATH_MAX` definition in util.h.

Added conditional inclusion of <bits/pthreadtypes.h> in db.c for
non-macOS systems. Included necessary headers for PATH_MAX and
NAME_MAX in src/log.c, src/postgres.c, and src/util.c when compiling
on macOS to ensure compatibility across different platforms.

Signed-off-by: Charalampos Mitrodimas <charmitro@posteo.net>
  • Loading branch information
charmitro authored and panosfol committed Sep 16, 2024
1 parent 69c0ea3 commit fe47482
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 2 deletions.
2 changes: 0 additions & 2 deletions include/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@

#ifdef _POSIX_C_SOURCE
#include <limits.h>
#else
#define PATH_MAX 4096
#endif

/* Write/Read end for pipes */
Expand Down
2 changes: 2 additions & 0 deletions src/db.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
#include "db/postgres.h"
#include "log.h"

#if !defined(__APPLE__) || !defined(__MACH__)
#include <bits/pthreadtypes.h>
#endif
#include <stdlib.h>
#include <sys/errno.h>
#include <pthread.h>
Expand Down
3 changes: 3 additions & 0 deletions src/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#if defined(__APPLE__) && defined(__MACH__)
#include <sys/syslimits.h> /* Needed for NAME_MAX, PATH_MAX. */
#endif

#include "util.h"
#include "config.h"
Expand Down
1 change: 1 addition & 0 deletions src/postgres.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#if defined(__APPLE__) && defined(__MACH__)
#include <mach/error.h>
#include <sys/syslimits.h> /* Needed for NAME_MAX, PATH_MAX */
#else
#include <error.h>
#endif
Expand Down
3 changes: 3 additions & 0 deletions src/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
#include <unistd.h>
#include <sys/wait.h>
#include <sys/stat.h>
#if defined(__APPLE__) && defined(__MACH__)
#include <sys/syslimits.h> /* Needed for NAME_MAX. */
#endif

#include "util.h"
#include "log.h"
Expand Down

0 comments on commit fe47482

Please sign in to comment.