Skip to content

Commit

Permalink
Add autoconfig detection and workaround for daddr_t
Browse files Browse the repository at this point in the history
Some systems don't have daddr_t in sys/types.h, so workaround this
by detecting and replacing with long if it does not exist.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
  • Loading branch information
Colin Ian King committed May 28, 2020
1 parent 1207d9c commit 7e150ab
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Makefile.config
Expand Up @@ -1521,6 +1521,14 @@ $(info autoconfig: using csinl)
endif
endif

ifndef $(HAVE_DADDR_T)
HAVE_DADDR_T = $(shell $(MAKE) -f Makefile.config --no-print-directory $(HAVE_NOT) TEST_PROG=test-daddr_t have_test_prog)
ifeq ($(HAVE_DADDR_T),1)
CONFIG_CFLAGS += -DHAVE_DADDR_T
$(info autoconfig: using daddr_t)
endif
endif

ifndef $(HAVE_DARN)
HAVE_DARN = $(shell $(MAKE) -f Makefile.config --no-print-directory $(HAVE_NOT) TEST_PROG=test-darn have_test_prog)
ifeq ($(HAVE_DARN),1)
Expand Down
4 changes: 4 additions & 0 deletions stress-ng.h
Expand Up @@ -3752,7 +3752,11 @@ struct shim_statx {

/* old ustat struct */
struct shim_ustat {
#if defined(HAVE_DADDR_T)
daddr_t f_tfree;
#else
long f_tfree;
#endif
ino_t f_tinode;
char f_fname[6];
char f_fpack[6];
Expand Down
34 changes: 34 additions & 0 deletions test/test-daddr_t.c
@@ -0,0 +1,34 @@
/*
* Copyright (C) 2013-2020 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* This code is a complete clean re-write of the stress tool by
* Colin Ian King <colin.king@canonical.com> and attempts to be
* backwardly compatible with the stress tool by Amos Waterland
* <apw@rossby.metr.ou.edu> but has more stress tests and more
* functionality.
*
*/
#define _GNU_SOURCE

#include <sys/types.h>

int main(void)
{
daddr_t addr = 0;

(void)addr;
}

0 comments on commit 7e150ab

Please sign in to comment.