Commit Graph

16 Commits

Author SHA1 Message Date
Jakub Jelinek 7adcbafe45 Update copyright years. 2022-01-03 10:42:10 +01:00
Jakub Jelinek c057ed9c52 openmp: Fix up strtoul and strtoull uses in libgomp
Yesterday when working on numa_domains, I've noticed because of a bug
in my patch a hang on a large NUMA machine.  I've fixed the bug, but
also discovered that the hang was a result of making wrong assumptions
about strtoul/strtoull.  All the uses were for portability setting
errno = 0 before the calls and treating non-zero errno after the call
as invalid input, but for the case where there are no valid digits at
all strtoul may set errno to EINVAL, but doesn't have to and with
glibc doesn't do that.  So, this patch goes through all the strtoul calls
and next to errno != 0 checks adds also endptr == startptr check.
Haven't done it in places where we immediately reject strtoul returning 0
the same as we reject errno != 0, because strtoul must return 0 in the
case where it sets endptr to the start pointer.  In some spots the code
was using errno = 0; x = strtoul (p, &p, 10); if (errno) { /*invalid*/ }
and those spots had to be changed to
errno = 0; x = strtoul (p, &end, 10); if (errno || end == p) { /*invalid*/ }
p = end;

2021-10-15  Jakub Jelinek  <jakub@redhat.com>

	* env.c (parse_schedule): For strtoul or strtoull calls which don't
	clearly reject return value 0 as invalid handle the case where end
	pointer is the same as first argument as invalid.
	(parse_unsigned_long_1): Likewise.
	(parse_one_place): Likewise.
	(parse_places_var): Likewise.
	(parse_stacksize): Likewise.
	(parse_spincount): Likewise.
	(parse_affinity): Likewise.
	(parse_gomp_openacc_dim): Likewise.  Avoid strict aliasing violation.
	Make code valid C89.
	* config/linux/affinity.c (gomp_affinity_find_last_cache_level):
	For strtoul calls which don't clearly reject return value 0 as
	invalid handle the case where end pointer is the same as first
	argument as invalid.
	(gomp_affinity_init_level_1): Likewise.
	(gomp_affinity_init_numa_domains): Likewise.
	* config/rtems/proc.c (parse_thread_pools): Likewise.
2021-10-15 16:28:34 +02:00
Sebastian Huber 0f951b3dd3 RTEMS: Fix libgomp build
libgomp/

	* config/rtems/sem.h (gomp_sem_getcount): New function.
2021-01-18 07:24:56 +01:00
Jakub Jelinek 99dee82307 Update copyright years. 2021-01-04 10:26:59 +01:00
Jakub Jelinek 8d9254fc8a Update copyright years.
From-SVN: r279813
2020-01-01 12:51:42 +01:00
Sebastian Huber cb87fec331 libgomp: Reduce copy and paste for RTEMS
libgomp/

	* config/rtems/bar.c: Include "../linux/bar.c" and delete copy
	and paste code.

From-SVN: r267752
2019-01-09 06:16:05 +00:00
Sebastian Huber 30b4d0d0b9 libgomp: Avoid complex dependencies for RTEMS
libgomp/

	* config/rtems/affinity-fmt.c: New file.  Include affinity-fmt.c,
	undefining HAVE_GETPID and HAVE_GETHOSTNAME, and mapping fwrite to
	write.

From-SVN: r267751
2019-01-09 06:14:15 +00:00
Jakub Jelinek a554497024 Update copyright years.
From-SVN: r267494
2019-01-01 13:31:55 +01:00
Jakub Jelinek 85ec4feb11 Update copyright years.
From-SVN: r256169
2018-01-03 11:03:58 +01:00
Jakub Jelinek cbe34bb5ed Update copyright years.
From-SVN: r243994
2017-01-01 13:07:43 +01:00
Sebastian Huber e7a7f4bea8 [RTEMS] Use spin lock for pool management
libgomp/

	* libgomp/config/rtems/pool.h (gomp_thread_pool_reservoir): Use
	pthread_spinlock_t instead of gomp_mutex_t lock.
	(gomp_get_thread_pool): Likewise.
	(gomp_release_thread_pool): Likewise.
	* libgomp/config/rtems/proc.c (allocate_thread_pool_reservoir):
	Likewise.

From-SVN: r243181
2016-12-02 14:13:12 +00:00
Sebastian Huber d313d52cd5 [RTEMS] Fix libgomp for nthreads == 1
libgomp/

        * config/rtems/pool.h (gomp_get_thread_pool): Return proper
        thread pool in case nthreads == 1.

From-SVN: r243179
2016-12-02 14:10:33 +00:00
Jakub Jelinek 818ab71a41 Update copyright years.
From-SVN: r232055
2016-01-04 15:30:50 +01:00
Sebastian Huber 06441dd5e3 [gomp] Add thread attribute customization
libgomp/ChangeLog

	* config/posix/pool.h (gomp_adjust_thread_attr): New.
	* config/rtems/pool.h (gomp_adjust_thread_attr): Likewise.
	(gomp_thread_pool_reservoir): Add priority member.
	* confi/rtems/proc.c (allocate_thread_pool_reservoir): Add
	priority.
	(parse_thread_pools): Likewise.
	* team.c (gomp_team_start): Call configuration provided
	gomp_adjust_thread_attr(). Destroy thread attributes if
	necessary.
	* libgomp.texi: Document GOMP_RTEMS_THREAD_POOLS.

From-SVN: r227442
2015-09-03 11:34:28 +00:00
Sebastian Huber 66c59f9238 [gomp] Thread pool management
libgomp/ChangeLog

	* config/posix/pool.h: New.
	* config/rtems/pool.h: Likewise.
	* config/rtems/proc.c: Likewise.
	* libgomp.h (gomp_thread_destructor): Declare.
	* team.c: Include configuration provided "pool.h".
	(gomp_get_thread_pool): Define in configuration.
	(gomp_team_end): Call configuration defined
	gomp_release_thread_pool().

From-SVN: r227441
2015-09-03 11:29:59 +00:00
Sebastian Huber 13c41b2e3e [gomp] Add RTEMS configuration
libgomp/ChangeLog

	* config/rtems/bar.c: New.
	* config/rtems/bar.h: Likewise.
	* config/rtems/mutex.c: Likewise.
	* config/rtems/mutex.h: Likewise.
	* config/rtems/sem.c: Likewise.
	* config/rtems/sem.h: Likewise.
	* configure.ac (*-*-rtems*): Check that Newlib provides a proper
	<sys/lock.h> header file.
	* configure.tgt (*-*-rtems*): Enable RTEMS configuration if
	supported by Newlib.
	* configure: Regenerate.

From-SVN: r227440
2015-09-03 11:26:36 +00:00