compile correctly with -std=c99
This patch enables correct compilation on both MacOS and Linux using only POSIX.1-2008-compliant C with XSI extensions. Specifically, POSIX.1-2008 is the minimum version because we use strdup(3); explicit XSI is required to expose putenv from glibc.master
parent
bd53ce959d
commit
87c5c9ef04
11
configure.ac
11
configure.ac
|
@ -19,6 +19,17 @@ AM_INIT_AUTOMAKE([check-news dist-bzip2 gnu no-define foreign subdir-objects])
|
||||||
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
|
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
|
||||||
AM_MAINTAINER_MODE
|
AM_MAINTAINER_MODE
|
||||||
|
|
||||||
|
# Check for system-specific stuff
|
||||||
|
case "${host_os}" in
|
||||||
|
*linux*)
|
||||||
|
;;
|
||||||
|
*darwin*)
|
||||||
|
CPPFLAGS="${CPPFLAGS} -D_DARWIN_C_SOURCE"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
# Checks for programs
|
# Checks for programs
|
||||||
|
|
||||||
# We can't do anything without a working MPI
|
# We can't do anything without a working MPI
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define _XOPEN_SOURCE 700
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define _XOPEN_SOURCE 700
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
|
11
src/aiori.c
11
src/aiori.c
|
@ -12,8 +12,19 @@
|
||||||
*
|
*
|
||||||
\******************************************************************************/
|
\******************************************************************************/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define _XOPEN_SOURCE 700
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#if defined(HAVE_STRINGS_H)
|
||||||
|
#include <strings.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "aiori.h"
|
#include "aiori.h"
|
||||||
|
|
||||||
#if defined(HAVE_SYS_STATVFS_H)
|
#if defined(HAVE_SYS_STATVFS_H)
|
||||||
|
|
29
src/ior.c
29
src/ior.c
|
@ -12,6 +12,8 @@
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define _XOPEN_SOURCE 700
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
@ -20,6 +22,11 @@
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <mpi.h>
|
#include <mpi.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#if defined(HAVE_STRINGS_H)
|
||||||
|
#include <strings.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <sys/stat.h> /* struct stat */
|
#include <sys/stat.h> /* struct stat */
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
|
@ -458,12 +465,16 @@ static int CountErrors(IOR_param_t * test, int access, int errors)
|
||||||
*/
|
*/
|
||||||
static void *aligned_buffer_alloc(size_t size)
|
static void *aligned_buffer_alloc(size_t size)
|
||||||
{
|
{
|
||||||
size_t pageSize;
|
|
||||||
size_t pageMask;
|
size_t pageMask;
|
||||||
char *buf, *tmp;
|
char *buf, *tmp;
|
||||||
char *aligned;
|
char *aligned;
|
||||||
|
|
||||||
pageSize = getpagesize();
|
#ifdef HAVE_GETPAGESIZE
|
||||||
|
size_t pageSize = getpagesize();
|
||||||
|
#else
|
||||||
|
long pageSize = sysconf(_SC_PAGESIZE);
|
||||||
|
#endif
|
||||||
|
|
||||||
pageMask = pageSize - 1;
|
pageMask = pageSize - 1;
|
||||||
buf = malloc(size + pageSize + sizeof(void *));
|
buf = malloc(size + pageSize + sizeof(void *));
|
||||||
if (buf == NULL)
|
if (buf == NULL)
|
||||||
|
@ -1410,7 +1421,7 @@ static void TestIoSys(IOR_test_t *test)
|
||||||
/* random process offset reading */
|
/* random process offset reading */
|
||||||
if (params->reorderTasksRandom) {
|
if (params->reorderTasksRandom) {
|
||||||
/* this should not intefere with randomOffset within a file because GetOffsetArrayRandom */
|
/* this should not intefere with randomOffset within a file because GetOffsetArrayRandom */
|
||||||
/* seeds every random() call */
|
/* seeds every rand() call */
|
||||||
int nodeoffset;
|
int nodeoffset;
|
||||||
unsigned int iseed0;
|
unsigned int iseed0;
|
||||||
nodeoffset = params->taskPerNodeOffset;
|
nodeoffset = params->taskPerNodeOffset;
|
||||||
|
@ -1762,11 +1773,11 @@ static IOR_offset_t *GetOffsetArrayRandom(IOR_param_t * test, int pretendRank,
|
||||||
|
|
||||||
/* set up seed for random() */
|
/* set up seed for random() */
|
||||||
if (access == WRITE || access == READ) {
|
if (access == WRITE || access == READ) {
|
||||||
test->randomSeed = seed = random();
|
test->randomSeed = seed = rand();
|
||||||
} else {
|
} else {
|
||||||
seed = test->randomSeed;
|
seed = test->randomSeed;
|
||||||
}
|
}
|
||||||
srandom(seed);
|
srand(seed);
|
||||||
|
|
||||||
fileSize = test->blockSize * test->segmentCount;
|
fileSize = test->blockSize * test->segmentCount;
|
||||||
if (test->filePerProc == FALSE) {
|
if (test->filePerProc == FALSE) {
|
||||||
|
@ -1778,7 +1789,7 @@ static IOR_offset_t *GetOffsetArrayRandom(IOR_param_t * test, int pretendRank,
|
||||||
if (test->filePerProc == FALSE) {
|
if (test->filePerProc == FALSE) {
|
||||||
// this counts which process get how many transferes in
|
// this counts which process get how many transferes in
|
||||||
// a shared file
|
// a shared file
|
||||||
if ((random() % test->numTasks) == pretendRank) {
|
if ((rand() % test->numTasks) == pretendRank) {
|
||||||
offsets++;
|
offsets++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1800,9 +1811,9 @@ static IOR_offset_t *GetOffsetArrayRandom(IOR_param_t * test, int pretendRank,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* fill with offsets (pass 2) */
|
/* fill with offsets (pass 2) */
|
||||||
srandom(seed); /* need same seed to get same transfers as counted in the beginning*/
|
srand(seed); /* need same seed to get same transfers as counted in the beginning*/
|
||||||
for (i = 0; i < fileSize; i += test->transferSize) {
|
for (i = 0; i < fileSize; i += test->transferSize) {
|
||||||
if ((random() % test->numTasks) == pretendRank) {
|
if ((rand() % test->numTasks) == pretendRank) {
|
||||||
offsetArray[offsetCnt] = i;
|
offsetArray[offsetCnt] = i;
|
||||||
offsetCnt++;
|
offsetCnt++;
|
||||||
}
|
}
|
||||||
|
@ -1810,7 +1821,7 @@ static IOR_offset_t *GetOffsetArrayRandom(IOR_param_t * test, int pretendRank,
|
||||||
}
|
}
|
||||||
/* reorder array */
|
/* reorder array */
|
||||||
for (i = 0; i < offsets; i++) {
|
for (i = 0; i < offsets; i++) {
|
||||||
value = random() % offsets;
|
value = rand() % offsets;
|
||||||
tmp = offsetArray[value];
|
tmp = offsetArray[value];
|
||||||
offsetArray[value] = offsetArray[i];
|
offsetArray[value] = offsetArray[i];
|
||||||
offsetArray[i] = tmp;
|
offsetArray[i] = tmp;
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
* $Date: 2013/11/27 17:05:31 $
|
* $Date: 2013/11/27 17:05:31 $
|
||||||
* $Author: brettkettering $
|
* $Author: brettkettering $
|
||||||
*/
|
*/
|
||||||
|
#define _XOPEN_SOURCE 700
|
||||||
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
@ -59,6 +60,11 @@
|
||||||
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#if HAVE_STRINGS_H
|
||||||
|
#include <strings.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
@ -1616,7 +1622,7 @@ void valid_tests() {
|
||||||
FAIL("-c not compatible with -B");
|
FAIL("-c not compatible with -B");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( strcasecmp(backend_name, "POSIX") != 0 && strcasecmp(backend_name, "DUMMY") != 0) {
|
if (strcasecmp(backend_name, "POSIX") != 0 && strcasecmp(backend_name, "DUMMY") != 0) {
|
||||||
FAIL("-a only supported interface is POSIX (and DUMMY) right now!");
|
FAIL("-a only supported interface is POSIX (and DUMMY) right now!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#define _XOPEN_SOURCE 700
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
|
@ -16,11 +16,16 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define _XOPEN_SOURCE 700
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#if defined(HAVE_STRINGS_H)
|
||||||
|
#include <strings.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "utilities.h"
|
#include "utilities.h"
|
||||||
#include "ior.h"
|
#include "ior.h"
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
# These options will be passed directly to the autoconf configure script
|
# These options will be passed directly to the autoconf configure script
|
||||||
CONFIGURE_OPTS="${CONFIGURE_OPTS:-""}"
|
CONFIGURE_OPTS="${CONFIGURE_OPTS:-"CFLAGS=-std=c99 --disable-silent-rules"}"
|
||||||
|
|
||||||
BASE_DIR="$(cd "${0%/*}" && pwd)"
|
BASE_DIR="$(cd "${0%/*}" && pwd)"
|
||||||
if [ -z "$BASE_DIR" -o ! -d "$BASE_DIR" ]; then
|
if [ -z "$BASE_DIR" -o ! -d "$BASE_DIR" ]; then
|
||||||
|
|
Loading…
Reference in New Issue