Skip to content

Commit

Permalink
always define _GNU_SOURCE and _DEFAULT_SOURCE
Browse files Browse the repository at this point in the history
  • Loading branch information
Duncaen committed Sep 1, 2023
1 parent 6341168 commit 76ec0f2
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 69 deletions.
2 changes: 0 additions & 2 deletions bin/xbps-fbulk/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@
* Only one attempt is made to build any given package, no matter how many
* other packages depend on it.
*/
#define _DEFAULT_SOURCE
#define _BSD_SOURCE

#include <sys/file.h>
#include <sys/stat.h>
Expand Down
6 changes: 0 additions & 6 deletions bin/xbps-query/search.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifdef HAVE_STRCASESTR
# define _GNU_SOURCE /* for strcasestr(3) */
#endif

#include "compat.h"

#include <assert.h>
#include <errno.h>
#include <fnmatch.h>
Expand Down
30 changes: 15 additions & 15 deletions bin/xbps-uchroot/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,28 @@
* - Supports overlayfs on a temporary directory or a tmpfs mount.
* - Supports read-only bind mounts.
*/
#define _GNU_SOURCE
#define _XOPEN_SOURCE 700
#include <sys/types.h>
#include <sys/prctl.h>

#include <sys/fsuid.h>
#include <sys/mount.h>
#include <sys/prctl.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include <stdarg.h>
#include <string.h>

#include <assert.h>
#include <stdlib.h>
#include <sched.h>
#include <limits.h> /* PATH_MAX */
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <ftw.h>
#include <signal.h>
#include <getopt.h>
#include <dirent.h>
#include <limits.h>
#include <sched.h>
#include <signal.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

#include <xbps.h>
#include "queue.h"
Expand Down
25 changes: 13 additions & 12 deletions bin/xbps-uunshare/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,26 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define _GNU_SOURCE
#include <sys/types.h>
#include <sys/mount.h>

#include <sys/fsuid.h>
#include <sys/mount.h>
#include <sys/types.h>
#include <sys/wait.h>

#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
#include <grp.h>
#include <limits.h>
#include <sched.h>
#include <signal.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <stdarg.h>
#include <signal.h>
#include <fcntl.h>
#include <grp.h>
#include <errno.h>
#include <limits.h>
#include <syscall.h>
#include <assert.h>
#include <getopt.h>
#include <unistd.h>

#include <xbps.h>
#include "queue.h"
Expand Down
3 changes: 2 additions & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,10 @@ if [ -n "$FULL_DEBUG" ]; then
echo "CPPFLAGS+= -DFULL_DEBUG" >>$CONFIG_MK
fi

echo "CPPFLAGS += -D_DEFAULT_SOURCE" >>$CONFIG_MK
echo "CPPFLAGS += -D_GNU_SOURCE" >>$CONFIG_MK
case "$OS" in
linux)
echo "CPPFLAGS += -D_XOPEN_SOURCE=700" >>$CONFIG_MK
echo "CPPFLAGS += -D_FILE_OFFSET_BITS=64" >> $CONFIG_MK
;;
*)
Expand Down
4 changes: 0 additions & 4 deletions lib/cb_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifdef HAVE_VASPRINTF
# define _GNU_SOURCE /* for vasprintf(3) */
#endif

#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
Expand Down
8 changes: 2 additions & 6 deletions lib/external/fexec.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,15 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

#define _BSD_SOURCE /* for vfork and chroot */
#define _DEFAULT_SOURCE /* glibc>=2.20 */
#include <sys/types.h>
#include <unistd.h>

#include <sys/wait.h>

#include <errno.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

#undef _DEFAULT_SOURCE
#undef _BSD_SOURCE
#include "xbps_api_impl.h"

static int
Expand Down
5 changes: 0 additions & 5 deletions lib/fetch/ftp.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,6 @@
*
*/

#ifdef __linux__
/* Keep this down to Linux, it can create surprises else where. */
#define _GNU_SOURCE
#endif

#include <sys/types.h>
#include <sys/socket.h>

Expand Down
4 changes: 0 additions & 4 deletions lib/fetch/http.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@
* SUCH DAMAGE.
*/

#if defined(__linux__)
#define _GNU_SOURCE
#endif

#include <sys/types.h>
#include <sys/socket.h>

Expand Down
4 changes: 1 addition & 3 deletions lib/portableproplib/prop_object.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@
static pthread_mutex_t _prop_refcnt_mtx = PTHREAD_MUTEX_INITIALIZER;
#endif /* _PROP_NEED_REFCNT_MTX */

#define __USE_MISC /* MAP_ANON on glibc */
# include <sys/mman.h>
#undef __USE_MISC
#include <sys/mman.h>
#include <sys/stat.h>
#include <errno.h>
#include <fcntl.h>
Expand Down
12 changes: 1 addition & 11 deletions lib/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,6 @@
* (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 HAVE_VASPRINTF
# define _GNU_SOURCE /* for vasprintf(3) */
#endif

#if defined(HAVE_STRLCAT) || defined(HAVE_STRLCPY)
# define _BSD_SOURCE
#endif

#include "compat.h"

#include <sys/utsname.h>

#include <assert.h>
Expand All @@ -47,6 +36,7 @@
#include <stdlib.h>
#include <string.h>

#include "compat.h"
#include "xbps_api_impl.h"

#ifdef __clang__
Expand Down

0 comments on commit 76ec0f2

Please sign in to comment.