Hello community, here is the log from the commit of package stress-ng for openSUSE:Factory checked in at 2017-11-10 14:57:45 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/stress-ng (Old) and /work/SRC/openSUSE:Factory/.stress-ng.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "stress-ng" Fri Nov 10 14:57:45 2017 rev:21 rq:540201 version:0.09.02 Changes: -------- --- /work/SRC/openSUSE:Factory/stress-ng/stress-ng.changes 2017-11-08 15:14:08.045285828 +0100 +++ /work/SRC/openSUSE:Factory/.stress-ng.new/stress-ng.changes 2017-11-10 14:57:58.690817746 +0100 @@ -1,0 +2,30 @@ +Thu Nov 9 10:00:38 UTC 2017 - [email protected] + +- Update to version 0.09.02 + * Makefile: bump version + * Manual: update contributors names and date + * README: update, add OS X instructions and add clean rule + * shim: cast to int for brk for __APPLE__ + * stress-ng.h: fix missing _ off __APPLE_ macro name + * Use shim_sbrk and shim_brk wrappers + * Add shim for brk and sbrk + * stress-pthread: use shim_sched_yield instead if pthread_yield + * stress-ng.h: use shim spinlock in warn_once inline helper + * pthreads: shim spinlocks so we can use mutex if not available + * Makefile.config: add missing ( + * Make BSD library more flexible, especially with __APPLE__ arch + * stress-inode-flags: reset flags to zero at end of loop (LP: #1730297) + * stress-inode-flags: move counter to bump once per loop iteration + * stress-random: enable random stressor for __APPLE__ arch + * stress-filename: default to POSIX filename chars for __APPLE__ + * stress-filename: OS X can't have ':' in filenames + * stress-fcntl: fix up incorrect name of failed system call + * stress-fcntl: remove need for 2nd fd in F_DUPFD + * stress-mmap: add MAC OS X mmap flags + * stress-schedpolicy: disable this for __APPLE__ arch + * sched: detect __APPLE__ and don't used sched funcs for this arch + * stress-zlib: correct text start/end for all OS choices + * test/test-libpthread: ensure we check all pthread functionality + * Update README.Android notes + +------------------------------------------------------------------- Old: ---- stress-ng-0.09.01.tar.gz New: ---- stress-ng-0.09.02.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ stress-ng.spec ++++++ --- /var/tmp/diff_new_pack.aCTKRO/_old 2017-11-10 14:58:00.066767976 +0100 +++ /var/tmp/diff_new_pack.aCTKRO/_new 2017-11-10 14:58:00.070767831 +0100 @@ -18,7 +18,7 @@ Name: stress-ng -Version: 0.09.01 +Version: 0.09.02 Release: 0 Summary: Tool to load and stress a computer License: GPL-2.0 ++++++ stress-ng-0.09.01.tar.gz -> stress-ng-0.09.02.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/stress-ng-0.09.01/Makefile new/stress-ng-0.09.02/Makefile --- old/stress-ng-0.09.01/Makefile 2017-11-02 17:23:16.000000000 +0100 +++ new/stress-ng-0.09.02/Makefile 2017-11-07 15:55:41.000000000 +0100 @@ -16,7 +16,7 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # -VERSION=0.09.01 +VERSION=0.09.02 # # Codename "harmful hardware harasser" # diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/stress-ng-0.09.01/Makefile.config new/stress-ng-0.09.02/Makefile.config --- old/stress-ng-0.09.01/Makefile.config 2017-11-02 17:23:16.000000000 +0100 +++ new/stress-ng-0.09.02/Makefile.config 2017-11-07 15:55:41.000000000 +0100 @@ -21,7 +21,9 @@ APPARMOR_PARSER=/sbin/apparmor_parser LIB_APPARMOR := -lapparmor +ifneq ($(shell uname -s),Darwin) LIB_BSD := -lbsd +endif LIB_Z := -lz LIB_CRYPT := -lcrypt LIB_RT := -lrt @@ -68,7 +70,7 @@ ifeq ($(HAVE_LIB_BSD),1) CONFIG_CFLAGS += -DHAVE_LIB_BSD CONFIG_LDFLAGS += $(LIB_BSD) -$(info autoconfig: using $(LIB_BSD)) +$(info autoconfig: using libbsd functions) endif endif @@ -108,6 +110,14 @@ endif endif +ifndef $(HAVE_LIB_PTHREAD_SPINLOCK) +HAVE_LIB_PTHREAD_SPINLOCK = $(shell $(MAKE) -f Makefile.config --no-print-directory $(HAVE_NOT) have_lib_pthread_spinlock) +ifeq ($(HAVE_LIB_PTHREAD_SPINLOCK),1) + CONFIG_CFLAGS += -DHAVE_LIB_PTHREAD_SPINLOCK +$(info autoconfig: using pthread spinlock) +endif +endif + ifndef $(HAVE_LIB_SCTP) HAVE_LIB_SCTP = $(shell $(MAKE) -f Makefile.config --no-print-directory $(HAVE_NOT) have_lib_sctp) ifeq ($(HAVE_LIB_SCTP),1) @@ -587,6 +597,19 @@ @rm -f $(DIR)/test-libpthread # +# check if we can build against libpthread +# +.PHONY: have_lib_pthread_spinlock +have_lib_pthread_spinlock: $(DIR)/test-libpthread-spinlock.c + @$(CC) $(CFLAGS) $(CPPFLAGS) $(DIR)/test-libpthread-spinlock.c $(LIB_PTHREAD) -o $(DIR)/test-libpthread-spinlock 2> /dev/null || true + @if [ -f $(DIR)/test-libpthread-spinlock ]; then \ + echo 1 ;\ + else \ + echo 0 ;\ + fi + @rm -f $(DIR)/test-libpthread-spinlock + +# # check if we can build against libsctp # .PHONY: have_lib_sctp diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/stress-ng-0.09.01/README new/stress-ng-0.09.02/README --- old/stress-ng-0.09.01/README 2017-11-02 17:23:16.000000000 +0100 +++ new/stress-ng-0.09.02/README 2017-11-07 15:55:41.000000000 +0100 @@ -42,18 +42,27 @@ functionality disabled if the support libraries are not installed. To build on BSD systems, one requires gcc and GNU make: - CC=gcc gmake + CC=gcc gmake clean + CC=gcc gmake + +To build on OS X systems, just use: + make clean + make To build on MINIX, gmake and clang are required: - CC=clang gmake + CC=clang gmake clean + CC=clang gmake To build on SunOS, one requires GCC and GNU make, build using: + CC=gcc gmake clean CC=gcc gmake To build a static image (example, for Android), use: + make clean STATIC=1 make To build with full warnings enabled: + make clean PEDANTIC=1 make For more information, see: http://kernel.ubuntu.com/~cking/stress-ng/ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/stress-ng-0.09.01/README.Android new/stress-ng-0.09.02/README.Android --- old/stress-ng-0.09.01/README.Android 2017-11-02 17:23:16.000000000 +0100 +++ new/stress-ng-0.09.02/README.Android 2017-11-07 15:55:41.000000000 +0100 @@ -36,6 +36,15 @@ export CC=${CROSS_COMPILE} STATIC=1 make ARCH=arm += Ubuntu 17.04 = +Considerably easier with a cross-compilation enable distribution, swap architecture as needed. + +=== Setup === + apt-get install gcc-4.9-aarch64-linux-gnu + +=== Build === + + CC=aarch64-linux-gnu-gcc-4.9 STATIC=1 make M.Srikanth Kumar, Jul 14, 2015 Colin Ian King, Dec 6, 2016 (updated, static linking) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/stress-ng-0.09.01/sched.c new/stress-ng-0.09.02/sched.c --- old/stress-ng-0.09.01/sched.c 2017-11-02 17:23:16.000000000 +0100 +++ new/stress-ng-0.09.02/sched.c 2017-11-07 15:55:41.000000000 +0100 @@ -25,7 +25,7 @@ #include "stress-ng.h" #if (defined(_POSIX_PRIORITY_SCHEDULING) || defined(__linux__)) && \ - !defined(__OpenBSD__) && !defined(__minix__) + !defined(__OpenBSD__) && !defined(__minix__) && !defined(__APPLE__) /* * get_sched_name() * convert sched class to human readable string @@ -64,7 +64,7 @@ #endif #if (defined(_POSIX_PRIORITY_SCHEDULING) || defined(__linux__)) && \ - !defined(__OpenBSD__) && !defined(__minix__) + !defined(__OpenBSD__) && !defined(__minix__) && !defined(__APPLE__) /* * set_sched() * are sched settings valid, if so, set them diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/stress-ng-0.09.01/shim.c new/stress-ng-0.09.02/shim.c --- old/stress-ng-0.09.01/shim.c 2017-11-02 17:23:16.000000000 +0100 +++ new/stress-ng-0.09.02/shim.c 2017-11-07 15:55:41.000000000 +0100 @@ -250,7 +250,7 @@ { #if defined(__linux__) && defined(__NR_getrandom) return syscall(__NR_getrandom, buff, buflen, flags); -#elif defined(__OpenBSD__) +#elif defined(__OpenBSD__) || defined(__APPLE__) (void)flags; return getentropy(buff, buflen); @@ -985,3 +985,25 @@ return -1; #endif } + +/* + * shim_brk() + * brk system call shim + */ +int shim_brk(void *addr) +{ +#if defined(__APPLE__) + return (int)brk(addr); +#else + return brk(addr); +#endif +} + +/* + * shim_sbrk() + * sbrk system call shim + */ +void *shim_sbrk(intptr_t increment) +{ + return sbrk(increment); +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/stress-ng-0.09.01/stress-brk.c new/stress-ng-0.09.02/stress-brk.c --- old/stress-ng-0.09.01/stress-brk.c 2017-11-02 17:23:16.000000000 +0100 +++ new/stress-ng-0.09.02/stress-brk.c 2017-11-07 15:55:41.000000000 +0100 @@ -100,7 +100,7 @@ /* Make sure this is killable by OOM killer */ set_oom_adjustment(args->name, true); - start_ptr = sbrk(0); + start_ptr = shim_sbrk(0); if (start_ptr == (void *) -1) { pr_fail_err("sbrk(0)"); exit(EXIT_FAILURE); @@ -112,17 +112,17 @@ i++; if (i > 8) { i = 0; - ptr = sbrk(0); + ptr = shim_sbrk(0); ptr -= page_size; - if (brk(ptr) < 0) + if (shim_brk(ptr) < 0) ptr = (void *)-1; } else { - ptr = sbrk((intptr_t)page_size); + ptr = shim_sbrk((intptr_t)page_size); } if (ptr == (void *)-1) { if ((errno == ENOMEM) || (errno == EAGAIN)) { nomems++; - if (brk(start_ptr) < 0) { + if (shim_brk(start_ptr) < 0) { pr_err("%s: brk(%p) failed: errno=%d (%s)\n", args->name, start_ptr, errno, strerror(errno)); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/stress-ng-0.09.01/stress-fcntl.c new/stress-ng-0.09.02/stress-fcntl.c --- old/stress-ng-0.09.01/stress-fcntl.c 2017-11-02 17:23:16.000000000 +0100 +++ new/stress-ng-0.09.02/stress-fcntl.c 2017-11-07 15:55:41.000000000 +0100 @@ -24,40 +24,6 @@ */ #include "stress-ng.h" -#if !defined(__minix__) -/* - * fd_available() - * return true if a fd is not being used - */ -static inline bool fd_available(const int fd) -{ - const int ret = fcntl(fd, F_GETFD); - - return ((ret == -1) && (errno == EBADF)); -} - -#if defined(F_DUPFD) || \ - defined(F_DUPFD_CLOEXEC) -/* - * fd_get() - * find a free fd to dup onto - */ -static int fd_get(void) -{ - int i; - - for (i = 0; i < 256; i++) { - int fd = mwc32() & 1023; - - if (fd_available(fd)) - return fd; - } - return -1; /* unlikely */ -} -#endif - -#endif - #if defined(F_DUPFD) || \ defined(F_DUPFD_CLOEXEC) || \ defined(F_GETFD) || \ @@ -102,27 +68,23 @@ { #if defined(F_DUPFD) && !defined(__minix__) { - int ret, fd2 = fd_get(); + int ret; - if (fd2 != -1) { - ret = fcntl(fd, F_DUPFD, fd2); - check_return(args, ret, "F_DUPFD"); - if (ret > -1) - (void)close(ret); - } + ret = fcntl(fd, F_DUPFD, 0); + check_return(args, ret, "F_DUPFD"); + if (ret > -1) + (void)close(ret); } #endif #if defined(F_DUPFD_CLOEXEC) && !defined(__minix__) { - int ret, fd2 = fd_get(); + int ret; - if (fd2 != -1) { - ret = fcntl(fd, F_DUPFD_CLOEXEC, mwc8()); - check_return(args, ret, "F_DUPFD_CLOEXEC"); - if (ret > -1) - (void)close(ret); - } + ret = fcntl(fd, F_DUPFD_CLOEXEC, 0); + check_return(args, ret, "F_DUPFD_CLOEXEC"); + if (ret > -1) + (void)close(ret); } #endif @@ -531,7 +493,7 @@ } while (g_keep_stressing_flag && ++retries < 100); if (retries >= 100) { - pr_err("%s: chmod: file %s took %d " + pr_err("%s: creat: file %s took %d " "retries to create (instance %" PRIu32 ")\n", args->name, filename, retries, args->instance); goto tidy; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/stress-ng-0.09.01/stress-filename.c new/stress-ng-0.09.02/stress-filename.c --- old/stress-ng-0.09.01/stress-filename.c 2017-11-02 17:23:16.000000000 +0100 +++ new/stress-ng-0.09.02/stress-filename.c 2017-11-07 15:55:41.000000000 +0100 @@ -92,6 +92,10 @@ if ((i == 0) || (i == '/')) continue; +#if defined(__APPLE__) + if (i == ':') + continue; +#endif *ptr = i; *(ptr + 1) = 'X'; *(ptr + 2) = '\0'; @@ -218,7 +222,11 @@ char *ptr; struct statvfs buf; size_t i, chars_allowed = 0, sz; +#if defined(__APPLE__) + uint8_t filename_opt = STRESS_FILENAME_POSIX; +#else uint8_t filename_opt = STRESS_FILENAME_PROBE; +#endif (void)get_setting("filename-opts", &filename_opt); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/stress-ng-0.09.01/stress-heapsort.c new/stress-ng-0.09.02/stress-heapsort.c --- old/stress-ng-0.09.01/stress-heapsort.c 2017-11-02 17:23:16.000000000 +0100 +++ new/stress-ng-0.09.02/stress-heapsort.c 2017-11-07 15:55:41.000000000 +0100 @@ -25,8 +25,6 @@ #include "stress-ng.h" #if defined(HAVE_LIB_BSD) -#include <bsd/stdlib.h> - static volatile bool do_jmp = true; static sigjmp_buf jmp_env; #endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/stress-ng-0.09.01/stress-inode-flags.c new/stress-ng-0.09.02/stress-inode-flags.c --- old/stress-ng-0.09.01/stress-inode-flags.c 2017-11-02 17:23:16.000000000 +0100 +++ new/stress-ng-0.09.02/stress-inode-flags.c 2017-11-07 15:55:41.000000000 +0100 @@ -32,7 +32,7 @@ static volatile bool keep_running; static sigset_t set; -static pthread_spinlock_t spinlock; +static shim_pthread_spinlock_t spinlock; /* * stress_inode_flags_ioctl() @@ -52,17 +52,9 @@ if (ret != 0) return; - ret = pthread_spin_lock(&spinlock); - if (!ret) { - inc_counter(args); - ret = pthread_spin_unlock(&spinlock); - (void)ret; - } - attr |= flag; ret = ioctl(fd, FS_IOC_SETFLAGS, &attr); - if (ret != 0) - return; + (void)ret; attr &= ~flag; ret = ioctl(fd, FS_IOC_SETFLAGS, &attr); @@ -70,6 +62,19 @@ } /* + * stress_inode_flags_ioctl_sane() + * set flags to a sane state so that file can be removed + */ +static inline void stress_inode_flags_ioctl_sane(const int fd) +{ + int ret; + const int flag = 0; + + ret = ioctl(fd, FS_IOC_SETFLAGS, &flag); + (void)ret; +} + +/* * stress_inode_flags_stressor() * exercise inode flags, see man ioctl_flags for * more details of these flags. Some are never going @@ -104,6 +109,8 @@ } while (keep_running && keep_stressing()) { + int ret; + stress_inode_flags_ioctl(args, fddir, 0); #if defined(FS_DIRSYNC_FL) stress_inode_flags_ioctl(args, fddir, FS_DIRSYNC_FL); @@ -117,7 +124,6 @@ #if defined(FS_TOPDIR_FL) stress_inode_flags_ioctl(args, fddir, FS_TOPDIR_FL); #endif - #if defined(FS_APPEND_LF) stress_inode_flags_ioctl(args, fdfile, FS_APPEND_FL); #endif @@ -151,7 +157,15 @@ #if defined(FS_UNRM_FL) stress_inode_flags_ioctl(args, fdfile, FS_UNRM_FL); #endif + ret = shim_pthread_spin_lock(&spinlock); + if (!ret) { + inc_counter(args); + ret = shim_pthread_spin_unlock(&spinlock); + (void)ret; + } + stress_inode_flags_ioctl_sane(fdfile); } + stress_inode_flags_ioctl_sane(fdfile); (void)close(fdfile); (void)close(fddir); } @@ -200,7 +214,7 @@ int rc, ret[MAX_INODE_FLAG_THREADS]; pthread_args_t pa; - rc = pthread_spin_init(&spinlock, 0); + rc = shim_pthread_spin_init(&spinlock, 0); if (rc) { pr_fail_errno("pthread_spin_init", rc); return EXIT_FAILURE; @@ -234,7 +248,7 @@ pthread_join(pthreads[i], NULL); } - (void)pthread_spin_destroy(&spinlock); + (void)shim_pthread_spin_destroy(&spinlock); (void)unlink(filename); stress_temp_dir_rm_args(args); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/stress-ng-0.09.01/stress-mergesort.c new/stress-ng-0.09.02/stress-mergesort.c --- old/stress-ng-0.09.01/stress-mergesort.c 2017-11-02 17:23:16.000000000 +0100 +++ new/stress-ng-0.09.02/stress-mergesort.c 2017-11-07 15:55:41.000000000 +0100 @@ -25,8 +25,6 @@ #include "stress-ng.h" #if defined(HAVE_LIB_BSD) -#include <bsd/stdlib.h> - static volatile bool do_jmp = true; static sigjmp_buf jmp_env; #endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/stress-ng-0.09.01/stress-mmap.c new/stress-ng-0.09.02/stress-mmap.c --- old/stress-ng-0.09.01/stress-mmap.c 2017-11-02 17:23:16.000000000 +0100 +++ new/stress-ng-0.09.02/stress-mmap.c 2017-11-07 15:55:41.000000000 +0100 @@ -46,6 +46,12 @@ #if defined(MAP_32BIT) && (defined(__x86_64__) || defined(__x86_64)) MAP_32BIT, #endif +#if defined(MAP_NOCACHE) /* Mac OS X */ + MAP_NOCACHE, +#endif +#if defined(MAP_HASSEMAPHORE) /* Mac OS X */ + MAP_HASSEMAPHORE, +#endif /* This will segv if no backing, so don't use it for now */ #if 0 && defined(MAP_NORESERVE) MAP_NORESERVE, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/stress-ng-0.09.01/stress-ng.1 new/stress-ng-0.09.02/stress-ng.1 --- old/stress-ng-0.09.01/stress-ng.1 2017-11-02 17:23:16.000000000 +0100 +++ new/stress-ng-0.09.02/stress-ng.1 2017-11-07 15:55:41.000000000 +0100 @@ -2,7 +2,7 @@ .\" First parameter, NAME, should be all caps .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection .\" other parameters are allowed: see man(7), man(1) -.TH STRESS-NG 1 "October 18, 2017" +.TH STRESS-NG 1 "November 7, 2017" .\" Please adjust this date whenever revising the manpage. .\" .\" Some roff macros, for reference: @@ -3395,7 +3395,7 @@ stress tool by Amos Waterland <[email protected]>. Thanks also for contributions from Abdul Haleem, Christian Ehrhardt, James Hunt, Jim Rowan, Joseph DeVincentis, Luca Pizzamiglio, Luis Henriques, -Manoj Iyer, Rob Colclaser, Tim Gardner and Zhiyi Sun. +Manoj Iyer, Matthew Tippett, Rob Colclaser, Tim Gardner and Zhiyi Sun. .SH NOTES Sending a SIGALRM, SIGINT or SIGHUP to stress-ng causes it to terminate all the stressor processes and ensures temporary files and diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/stress-ng-0.09.01/stress-ng.c new/stress-ng-0.09.02/stress-ng.c --- old/stress-ng-0.09.01/stress-ng.c 2017-11-02 17:23:16.000000000 +0100 +++ new/stress-ng-0.09.02/stress-ng.c 2017-11-07 15:55:41.000000000 +0100 @@ -3776,10 +3776,10 @@ * Setup spinlocks */ #if defined(STRESS_PERF_STATS) - pthread_spin_init(&g_shared->perf.lock, 0); + shim_pthread_spin_init(&g_shared->perf.lock, 0); #endif #if defined(HAVE_LIB_PTHREAD) - pthread_spin_init(&g_shared->warn_once.lock, 0); + shim_pthread_spin_init(&g_shared->warn_once.lock, 0); #endif /* diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/stress-ng-0.09.01/stress-ng.h new/stress-ng-0.09.02/stress-ng.h --- old/stress-ng-0.09.01/stress-ng.h 2017-11-02 17:23:16.000000000 +0100 +++ new/stress-ng-0.09.02/stress-ng.h 2017-11-07 15:55:41.000000000 +0100 @@ -58,6 +58,11 @@ #if defined(HAVE_LIB_PTHREAD) #include <pthread.h> #endif +#if defined(HAVE_LIB_BSD) && !defined(__APPLE__) +#include <bsd/stdlib.h> +#include <bsd/string.h> +#include <bsd/wchar.h> +#endif #include <signal.h> #include <time.h> #include <sys/file.h> @@ -71,7 +76,7 @@ #include <sys/ioctl.h> #include <sys/uio.h> #include <sys/resource.h> -#if defined (__linux__) +#if defined(__linux__) #include <sys/mount.h> #include <sys/syscall.h> #include <sys/quota.h> @@ -81,6 +86,9 @@ #include <linux/fiemap.h> #include <linux/posix_types.h> #endif +#if defined(__APPLE__) +#include <sys/random.h> +#endif #if defined(HAVE_SEM_SYSV) #include <sys/ipc.h> #include <sys/sem.h> @@ -997,6 +1005,24 @@ (*(args->counter))++; } +#if defined(HAVE_LIB_PTHREAD) +#if defined(HAVE_LIB_PTHREAD_SPINLOCK) +typedef pthread_spinlock_t shim_pthread_spinlock_t; + +#define shim_pthread_spin_lock(lock) pthread_spin_lock(lock) +#define shim_pthread_spin_unlock(lock) pthread_spin_unlock(lock) +#define shim_pthread_spin_init(lock, shared) pthread_spin_init(lock, shared) +#define shim_pthread_spin_destroy(lock) pthread_spin_destroy(lock) +#else +typedef pthread_mutex_t shim_pthread_spinlock_t; + +#define shim_pthread_spin_lock(lock) pthread_mutex_lock(lock) +#define shim_pthread_spin_unlock(lock) pthread_mutex_unlock(lock) +#define shim_pthread_spin_init(lock, shared) pthread_mutex_init(lock, shared) +#define shim_pthread_spin_destroy(lock) pthread_mutex_destroy(lock) +#endif +#endif + /* stress process prototype */ typedef int (*stress_func_t)(const args_t *args); @@ -1077,7 +1103,7 @@ struct { uint32_t flags; /* flag bits */ #if defined(HAVE_LIB_PTHREAD) - pthread_spinlock_t lock; /* protection lock */ + shim_pthread_spinlock_t lock; /* protection lock */ #endif } warn_once; uint32_t warn_once_flags; /* Warn once flags */ @@ -1106,7 +1132,7 @@ #if defined(STRESS_PERF_STATS) struct { bool no_perf; /* true = Perf not available */ - pthread_spinlock_t lock; /* spinlock on no_perf updates */ + shim_pthread_spinlock_t lock; /* spinlock on no_perf updates */ } perf; #endif #if defined(STRESS_THERMAL_ZONES) @@ -2370,12 +2396,12 @@ uint32_t tmp; #if defined(HAVE_LIB_PTHREAD) - pthread_spin_lock(&g_shared->warn_once.lock); + shim_pthread_spin_lock(&g_shared->warn_once.lock); #endif tmp = !(g_shared->warn_once.flags & flag); g_shared->warn_once.flags |= flag; #if defined(HAVE_LIB_PTHREAD) - pthread_spin_unlock(&g_shared->warn_once.lock); + shim_pthread_spin_unlock(&g_shared->warn_once.lock); #endif return tmp; } @@ -2695,7 +2721,8 @@ extern int shim_futex_wait(const void *futex, const int val, const struct timespec *timeout); extern int shim_dup3(int oldfd, int newfd, int flags); extern int shim_sync_file_range(int fd, shim_off64_t offset, shim_off64_t nbytes, unsigned int flags); - +extern int shim_brk(void *addr); +extern void *shim_sbrk(intptr_t increment); #define STRESS(func) extern int func(const args_t *args) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/stress-ng-0.09.01/stress-pthread.c new/stress-ng-0.09.02/stress-pthread.c --- old/stress-ng-0.09.01/stress-pthread.c 2017-11-02 17:23:16.000000000 +0100 +++ new/stress-ng-0.09.02/stress-pthread.c 2017-11-07 15:55:41.000000000 +0100 @@ -32,7 +32,7 @@ static pthread_cond_t cond; static pthread_mutex_t mutex; -static pthread_spinlock_t spinlock; +static shim_pthread_spinlock_t spinlock; static bool thread_terminate; static uint64_t pthread_count; static sigset_t set; @@ -111,13 +111,13 @@ /* * Bump count of running threads */ - ret = pthread_spin_lock(&spinlock); + ret = shim_pthread_spin_lock(&spinlock); if (ret) { pr_fail_errno("spinlock lock", ret); goto die; } pthread_count++; - ret = pthread_spin_unlock(&spinlock); + ret = shim_pthread_spin_unlock(&spinlock); if (ret) { pr_fail_errno("spin unlock", ret); goto die; @@ -138,9 +138,7 @@ pr_fail_errno("pthread condition wait", ret); break; } -#if !defined(__NetBSD__) && !defined(__sun__) - (void)pthread_yield(); -#endif + (void)shim_sched_yield(); } ret = pthread_mutex_unlock(&mutex); if (ret) @@ -182,7 +180,7 @@ pr_fail_errno("pthread_cond_init", ret); return EXIT_FAILURE; } - ret = pthread_spin_init(&spinlock, 0); + ret = shim_pthread_spin_init(&spinlock, 0); if (ret) { pr_fail_errno("pthread_spin_init", ret); return EXIT_FAILURE; @@ -284,7 +282,7 @@ (void)pthread_cond_destroy(&cond); (void)pthread_mutex_destroy(&mutex); - (void)pthread_spin_destroy(&spinlock); + (void)shim_pthread_spin_destroy(&spinlock); return EXIT_SUCCESS; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/stress-ng-0.09.01/stress-radixsort.c new/stress-ng-0.09.02/stress-radixsort.c --- old/stress-ng-0.09.01/stress-radixsort.c 2017-11-02 17:23:16.000000000 +0100 +++ new/stress-ng-0.09.02/stress-radixsort.c 2017-11-07 15:55:41.000000000 +0100 @@ -25,7 +25,6 @@ #include "stress-ng.h" #if HAVE_LIB_BSD -#include <bsd/stdlib.h> #define STR_SIZE (8) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/stress-ng-0.09.01/stress-resources.c new/stress-ng-0.09.02/stress-resources.c --- old/stress-ng-0.09.01/stress-resources.c 2017-11-02 17:23:16.000000000 +0100 +++ new/stress-ng-0.09.02/stress-resources.c 2017-11-07 15:55:41.000000000 +0100 @@ -148,7 +148,7 @@ break; } if (!(mwc32() & 0xf)) { - info[i].m_sbrk = sbrk(page_size); + info[i].m_sbrk = shim_sbrk(page_size); if (!g_keep_stressing_flag) break; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/stress-ng-0.09.01/stress-rlimit.c new/stress-ng-0.09.02/stress-rlimit.c --- old/stress-ng-0.09.01/stress-rlimit.c 2017-11-02 17:23:16.000000000 +0100 +++ new/stress-ng-0.09.02/stress-rlimit.c 2017-11-07 15:55:41.000000000 +0100 @@ -185,11 +185,11 @@ break; case 2: /* Trigger RLIMIT_DATA */ - oldbrk = sbrk(0); + oldbrk = shim_sbrk(0); if (oldbrk != (void *)-1) { - ptr = sbrk(MAX_RLIMIT_DATA); + ptr = shim_sbrk(MAX_RLIMIT_DATA); if (ptr != (void *)-1) { - int rc = brk(oldbrk); + int rc = shim_brk(oldbrk); (void)rc; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/stress-ng-0.09.01/stress-schedpolicy.c new/stress-ng-0.09.02/stress-schedpolicy.c --- old/stress-ng-0.09.01/stress-schedpolicy.c 2017-11-02 17:23:16.000000000 +0100 +++ new/stress-ng-0.09.02/stress-schedpolicy.c 2017-11-07 15:55:41.000000000 +0100 @@ -25,7 +25,7 @@ #include "stress-ng.h" #if (defined(_POSIX_PRIORITY_SCHEDULING) || defined(__linux__)) && \ - !defined(__OpenBSD__) && !defined(__minix__) + !defined(__OpenBSD__) && !defined(__minix__) && !defined(__APPLE__) static const int policies[] = { #if defined(SCHED_IDLE) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/stress-ng-0.09.01/stress-stack.c new/stress-ng-0.09.02/stress-stack.c --- old/stress-ng-0.09.01/stress-stack.c 2017-11-02 17:23:16.000000000 +0100 +++ new/stress-ng-0.09.02/stress-stack.c 2017-11-07 15:55:41.000000000 +0100 @@ -92,7 +92,7 @@ } } } else if (pid == 0) { - char *start_ptr = sbrk(0); + char *start_ptr = shim_sbrk(0); (void)setpgid(0, g_pgrp); stress_parent_died_alarm(); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/stress-ng-0.09.01/stress-str.c new/stress-ng-0.09.02/stress-str.c --- old/stress-ng-0.09.01/stress-str.c 2017-11-02 17:23:16.000000000 +0100 +++ new/stress-ng-0.09.02/stress-str.c 2017-11-07 15:55:41.000000000 +0100 @@ -26,7 +26,6 @@ #include <strings.h> #if defined(HAVE_LIB_BSD) -#include <bsd/string.h> #define HAVE_STRLCPY #define HAVE_STRLCAT #elif defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/stress-ng-0.09.01/stress-wcstr.c new/stress-ng-0.09.02/stress-wcstr.c --- old/stress-ng-0.09.01/stress-wcstr.c 2017-11-02 17:23:16.000000000 +0100 +++ new/stress-ng-0.09.02/stress-wcstr.c 2017-11-07 15:55:41.000000000 +0100 @@ -27,7 +27,6 @@ #include <wchar.h> #if defined(HAVE_LIB_BSD) -#include <bsd/wchar.h> #define HAVE_WCSLCAT #define HAVE_WCSLCPY #define HAVE_WCSNCASECMP diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/stress-ng-0.09.01/stress-zlib.c new/stress-ng-0.09.02/stress-zlib.c --- old/stress-ng-0.09.01/stress-zlib.c 2017-11-02 17:23:16.000000000 +0100 +++ new/stress-ng-0.09.02/stress-zlib.c 2017-11-07 15:55:41.000000000 +0100 @@ -319,19 +319,24 @@ static bool use_rand_data = false; struct sigaction sigsegv_orig, sigbus_orig; -#if defined(__OpenBSD__) +#if defined(__APPLE__) + extern void *get_etext(void); + char *text_start = get_etext(); +#elif defined(__OpenBSD__) extern char _start[]; + char *text_start = &_start[0]; #else - extern char __executable_start[]; + extern char etext; + char *text_start = &etext; #endif - extern char __etext; -#if defined(__OpenBSD__) - char *text_start = &_start[0]; +#if defined(__APPLE__) + extern void *get_edata(void); + char *text_end = get_edata(); #else - char *text_start = &__executable_start[0]; + extern char edata; + char *text_end = &edata; #endif - char *text_end = &__etext; static char *text = NULL; const size_t text_len = text_end - text_start; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/stress-ng-0.09.01/test/test-libbsd.c new/stress-ng-0.09.02/test/test-libbsd.c --- old/stress-ng-0.09.01/test/test-libbsd.c 2017-11-02 17:23:16.000000000 +0100 +++ new/stress-ng-0.09.02/test/test-libbsd.c 2017-11-07 15:55:41.000000000 +0100 @@ -23,7 +23,10 @@ * */ #include <string.h> +#include <stdlib.h> +#if !defined(__APPLE__) #include <bsd/stdlib.h> +#endif static int intcmp(const void *p1, const void *p2) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/stress-ng-0.09.01/test/test-libpthread-spinlock.c new/stress-ng-0.09.02/test/test-libpthread-spinlock.c --- old/stress-ng-0.09.01/test/test-libpthread-spinlock.c 1970-01-01 01:00:00.000000000 +0100 +++ new/stress-ng-0.09.02/test/test-libpthread-spinlock.c 2017-11-07 15:55:41.000000000 +0100 @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2013-2017 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 <[email protected]> and attempts to be + * backwardly compatible with the stress tool by Amos Waterland + * <[email protected]> but has more stress tests and more + * functionality. + * + */ +#include <pthread.h> + +/* The following functions from libpthread are used by stress-ng */ + +static void *pthread_funcs[] = { + (void *)pthread_spin_lock, + (void *)pthread_spin_unlock, + (void *)pthread_spin_init, + (void *)pthread_spin_destroy, +}; + +int main(void) +{ + return 0; +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/stress-ng-0.09.01/test/test-libpthread.c new/stress-ng-0.09.02/test/test-libpthread.c --- old/stress-ng-0.09.01/test/test-libpthread.c 2017-11-02 17:23:16.000000000 +0100 +++ new/stress-ng-0.09.02/test/test-libpthread.c 2017-11-07 15:55:41.000000000 +0100 @@ -28,7 +28,6 @@ /* The following functions from libpthread are used by stress-ng */ static void *pthread_funcs[] = { -#if defined(__linux__) (void *)sem_init, (void *)sem_destroy, (void *)sem_post, @@ -41,7 +40,6 @@ (void *)pthread_cond_broadcast, (void *)pthread_cond_destroy, (void *)pthread_mutex_destroy, -#endif }; int main(void)
