Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cmake/modules/Configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ check_include_file(g2c.h HAVE_G2C_H)
check_include_file(f2c.h HAVE_F2C_H)
check_include_file(cblas.h HAVE_CBLAS_H)
check_include_file(cblas-atlas.h HAVE_CBLAS_ATLAS_H)
check_include_file(stdatomic.h HAVE_STDATOMIC_H)
check_include_file(threads.h HAVE_THREADS_H)
check_include_file(complex.h HAVE_COMPLEX_H)

if(MSVC)
set(HAVE_PTHREAD_H 0)
Expand Down
103 changes: 103 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -7011,6 +7011,25 @@ then :

fi

ac_fn_c_check_header_compile "$LINENO" "stdatomic.h" "ac_cv_header_stdatomic_h" "$ac_includes_default"
if test "x$ac_cv_header_stdatomic_h" = xyes
then :
printf "%s\n" "#define HAVE_STDATOMIC_H 1" >>confdefs.h

fi
ac_fn_c_check_header_compile "$LINENO" "threads.h" "ac_cv_header_threads_h" "$ac_includes_default"
if test "x$ac_cv_header_threads_h" = xyes
then :
printf "%s\n" "#define HAVE_THREADS_H 1" >>confdefs.h

fi
ac_fn_c_check_header_compile "$LINENO" "complex.h" "ac_cv_header_complex_h" "$ac_includes_default"
if test "x$ac_cv_header_complex_h" = xyes
then :
printf "%s\n" "#define HAVE_COMPLEX_H 1" >>confdefs.h

fi


ac_fn_c_check_type "$LINENO" "off_t" "ac_cv_type_off_t" "$ac_includes_default"
if test "x$ac_cv_type_off_t" = xyes
Expand Down Expand Up @@ -15234,6 +15253,90 @@ fi



LDFLAGS=${ac_save_ldflags}


;;
esac
fi

LIBS=${ac_save_libs}
LDFLAGS=${ac_save_ldflags}



ac_save_libs="$LIBS"
ac_save_ldflags="$LDFLAGS"
LIBS=" $LIBS"
LDFLAGS=" $LDFLAGS"
ac_fn_c_check_func "$LINENO" "sched_yield" "ac_cv_func_sched_yield"
if test "x$ac_cv_func_sched_yield" = xyes
then :


PTHREADLIB="$PTHREADLIB "


else case e in #(
e)

ac_save_ldflags="$LDFLAGS"
LDFLAGS="$PTHREADLIBPATH $LDFLAGS"


{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for sched_yield in -lpthread" >&5
printf %s "checking for sched_yield in -lpthread... " >&6; }

ac_check_lib_save_LIBS=$LIBS
LIBS="-lpthread $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */

/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply.
The 'extern "C"' is for builds by C++ compilers;
although this is not generally supported in C code supporting it here
has little cost and some practical benefit (sr 110532). */
#ifdef __cplusplus
extern "C"
#endif
char sched_yield (void);
int
main (void)
{
return sched_yield ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"
then :
ac_cv_lib_pthread_sched_yield=yes
else case e in #(
e) ac_cv_lib_pthread_sched_yield=no ;;
esac
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthread_sched_yield" >&5
printf "%s\n" "$ac_cv_lib_pthread_sched_yield" >&6; }
if test "x$ac_cv_lib_pthread_sched_yield" = xyes
then :
PTHREADLIB="$PTHREADLIB -lpthread "
else case e in #(
e)
LDFLAGS=${ac_save_ldflags}

as_fn_error $? "*** Unable to locate POSIX threads library." "$LINENO" 5

;;
esac
fi



LDFLAGS=${ac_save_ldflags}


Expand Down
5 changes: 5 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@ AC_CHECK_HEADERS(sys/ioctl.h sys/mtio.h sys/resource.h sys/time.h)
AC_CHECK_HEADERS(sys/timeb.h sys/types.h sys/utsname.h)
AC_CHECK_HEADERS(libintl.h iconv.h)
AC_CHECK_HEADERS(langinfo.h)
AC_CHECK_HEADERS(stdatomic.h threads.h complex.h)

AC_TYPE_OFF_T
AC_TYPE_UID_T
Expand Down Expand Up @@ -1863,6 +1864,10 @@ LOC_CHECK_FUNC(pthread_create,POSIX threads functions,PTHREADLIB,,,,,[
LOC_CHECK_LIBS(pthread,pthread_create,POSIX threads,$PTHREADLIBPATH,PTHREADLIB,,,)
])

LOC_CHECK_FUNC(sched_yield,POSIX threads functions,PTHREADLIB,,,,,[
LOC_CHECK_LIBS(pthread,sched_yield,POSIX threads,$PTHREADLIBPATH,PTHREADLIB,,,)
])

if test -n "$PTHREADLIB" ; then
AC_DEFINE(HAVE_PTHREAD, 1, [Define to 1 if POSIX threads are available.])
fi
Expand Down
8 changes: 8 additions & 0 deletions include/grass/defs/gis.h
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,14 @@ void G_progress(long, int);
void G_set_percent_routine(int (*)(int));
void G_unset_percent_routine(void);

/* progress.c */
GProgressContext *G_progress_context_create(size_t, size_t);
GProgressContext *G_progress_context_create_time(size_t, long);
GProgressContext *G_progress_context_create_counter(size_t);
void G_progress_context_destroy(GProgressContext *);
void G_progress_update(GProgressContext *);
void G_progress_log(GProgressContext *, const char *);

/* popen.c */
void G_popen_clear(struct Popen *);
FILE *G_popen_write(struct Popen *, const char *, const char **);
Expand Down
30 changes: 30 additions & 0 deletions include/grass/gis.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,26 @@ static const char *GRASS_copyright G_UNUSED = "GRASS GNU GPL licensed Software";
#define G_FALLTHROUGH ((void)0)
#endif

/*!
\def G_HAVE_ATOMICS
\brief A macro that signals whether C11 atomic operations are supported.
*/
#if __STDC_VERSION__ < 201112L || defined(__STDC_NO_ATOMICS__)
#define G_HAVE_ATOMICS 0
#else
#define G_HAVE_ATOMICS 1
#endif

/*!
\def G_USE_PROGRESS_NG
\brief A macro indicating if concurrency progress reporting can be used.
*/
#if defined(G_HAVE_ATOMICS) && defined(HAVE_PTHREAD_H)
#define G_USE_PROGRESS_NG 1
#else
#define G_USE_PROGRESS_NG 0
#endif

/* GRASS version, GRASS date, git short hash of last change in GRASS headers
* (and anything else in include)
*/
Expand Down Expand Up @@ -727,6 +747,16 @@ struct ilist {
int alloc_values;
};

/*!
\brief Opaque handle that owns telemetry state for one progress-reporting
stream.

A `GProgressContext` isolates queued events, progress thresholds, and the
optional consumer thread used by the `G_progress_context_*()` APIs so that
concurrent operations can report progress independently.
*/
typedef struct GProgressContext GProgressContext;

/*============================== Prototypes ================================*/

/* Since there are so many prototypes for the gis library they are stored */
Expand Down
Loading
Loading