{
return (void *) syscall (__NR_gettid);
}
+
+/* For the affinity functions, there are systems which do not provide
+ the required support, so we create a wrapper to check its availability
+ before calling. */
+
+extern int pthread_setaffinity_np (pthread_t th,
+ size_t cpusetsize,
+ const void *cpuset)
+ __attribute__((weak));
+
+extern int pthread_attr_setaffinity_np (pthread_attr_t *__attr,
+ size_t cpusetsize,
+ const void *cpuset)
+ __attribute__((weak));
+
+int __gnat_pthread_setaffinity_np (pthread_t th,
+ size_t cpusetsize,
+ const void *cpuset);
+
+int __gnat_pthread_attr_setaffinity_np (pthread_attr_t *__attr,
+ size_t cpusetsize,
+ const void *cpuset);
+
+int
+__gnat_pthread_setaffinity_np (pthread_t th,
+ size_t cpusetsize,
+ const void *cpuset)
+{
+ /* Call the underlying OS operation if available */
+ if (pthread_setaffinity_np)
+ return pthread_setaffinity_np (th, cpusetsize, cpuset);
+ else
+ return 0;
+}
+
+int
+__gnat_pthread_attr_setaffinity_np (pthread_attr_t *__attr,
+ size_t cpusetsize,
+ const void *cpuset)
+{
+ /* Call the underlying OS operation if available */
+ if (pthread_attr_setaffinity_np)
+ return pthread_attr_setaffinity_np (__attr, cpusetsize, cpuset);
+ else
+ return 0;
+}
#endif
ada/gnatvsn.o \
ada/hlo.o \
ada/hostparm.o \
- ada/i-c.o \
- ada/i-cstrea.o \
ada/impunit.o \
ada/inline.o \
ada/interfac.o \
ada/system.ads ada/s-exctab.ads ada/s-stalib.ads ada/s-unstyp.ads \
ada/types.ads ada/unchconv.ads ada/unchdeal.ads
-ada/i-c.o : ada/ada.ads ada/a-except.ads ada/a-unccon.ads ada/interfac.ads \
- ada/i-c.ads ada/i-c.adb ada/system.ads ada/s-exctab.ads \
- ada/s-exctab.adb ada/s-htable.ads ada/s-parame.ads ada/s-secsta.ads \
- ada/s-soflin.ads ada/s-stache.ads ada/s-stalib.ads ada/s-stoele.ads \
- ada/s-stoele.adb ada/s-traent.ads
-
-ada/i-cstrea.o : ada/ada.ads ada/a-unccon.ads ada/interfac.ads \
- ada/i-cstrea.ads ada/i-cstrea.adb ada/system.ads ada/s-crtl.ads \
- ada/s-parame.ads
-
ada/impunit.o : ada/ada.ads ada/a-except.ads ada/a-unccon.ads \
ada/a-uncdea.ads ada/alloc.ads ada/aspects.ads ada/atree.ads \
ada/atree.adb ada/casing.ads ada/debug.ads ada/einfo.ads ada/einfo.adb \
ada/sem_cat.adb ada/sem_ch13.ads ada/sem_ch3.ads ada/sem_ch3.adb \
ada/sem_ch6.ads ada/sem_ch7.ads ada/sem_ch8.ads ada/sem_disp.ads \
ada/sem_dist.ads ada/sem_elim.ads ada/sem_eval.ads ada/sem_eval.adb \
- ada/sem_mech.ads ada/sem_res.ads ada/sem_smem.ads ada/sem_type.ads \
- ada/sem_util.ads ada/sem_util.adb ada/sem_warn.ads ada/sinfo.ads \
- ada/sinfo.adb ada/sinput.ads ada/snames.ads ada/sprint.ads \
- ada/stand.ads ada/stringt.ads ada/stringt.adb ada/style.ads \
- ada/styleg.ads ada/styleg.adb ada/stylesw.ads ada/system.ads \
- ada/s-crc32.ads ada/s-exctab.ads ada/s-htable.ads ada/s-imenne.ads \
- ada/s-memory.ads ada/s-os_lib.ads ada/s-parame.ads ada/s-rident.ads \
- ada/s-secsta.ads ada/s-soflin.ads ada/s-stache.ads ada/s-stalib.ads \
- ada/s-stoele.ads ada/s-stoele.adb ada/s-string.ads ada/s-traent.ads \
- ada/s-unstyp.ads ada/s-utf_32.ads ada/s-wchcon.ads ada/table.ads \
- ada/table.adb ada/targparm.ads ada/tbuild.ads ada/tbuild.adb \
- ada/tree_io.ads ada/ttypes.ads ada/types.ads ada/uintp.ads \
- ada/uintp.adb ada/uname.ads ada/unchconv.ads ada/unchdeal.ads \
- ada/urealp.ads ada/urealp.adb ada/validsw.ads ada/widechar.ads
+ ada/sem_mech.ads ada/sem_prag.ads ada/sem_res.ads ada/sem_smem.ads \
+ ada/sem_type.ads ada/sem_util.ads ada/sem_util.adb ada/sem_warn.ads \
+ ada/sinfo.ads ada/sinfo.adb ada/sinput.ads ada/snames.ads \
+ ada/sprint.ads ada/stand.ads ada/stringt.ads ada/stringt.adb \
+ ada/style.ads ada/styleg.ads ada/styleg.adb ada/stylesw.ads \
+ ada/system.ads ada/s-crc32.ads ada/s-exctab.ads ada/s-htable.ads \
+ ada/s-imenne.ads ada/s-memory.ads ada/s-os_lib.ads ada/s-parame.ads \
+ ada/s-rident.ads ada/s-secsta.ads ada/s-soflin.ads ada/s-stache.ads \
+ ada/s-stalib.ads ada/s-stoele.ads ada/s-stoele.adb ada/s-string.ads \
+ ada/s-traent.ads ada/s-unstyp.ads ada/s-utf_32.ads ada/s-wchcon.ads \
+ ada/table.ads ada/table.adb ada/targparm.ads ada/tbuild.ads \
+ ada/tbuild.adb ada/tree_io.ads ada/ttypes.ads ada/types.ads \
+ ada/uintp.ads ada/uintp.adb ada/uname.ads ada/unchconv.ads \
+ ada/unchdeal.ads ada/urealp.ads ada/urealp.adb ada/validsw.ads \
+ ada/widechar.ads
ada/sem_ch4.o : ada/ada.ads ada/a-except.ads ada/a-unccon.ads \
ada/a-uncdea.ads ada/alloc.ads ada/aspects.ads ada/atree.ads \
ada/sem_aux.ads ada/sem_cat.ads ada/sem_ch10.ads ada/sem_ch12.ads \
ada/sem_ch13.ads ada/sem_ch3.ads ada/sem_ch6.ads ada/sem_ch7.ads \
ada/sem_ch7.adb ada/sem_ch8.ads ada/sem_disp.ads ada/sem_eval.ads \
- ada/sem_prag.ads ada/sem_res.ads ada/sem_type.ads ada/sem_util.ads \
- ada/sem_util.adb ada/sem_warn.ads ada/sinfo.ads ada/sinfo.adb \
- ada/sinput.ads ada/sinput.adb ada/snames.ads ada/snames.adb \
- ada/stand.ads ada/stringt.ads ada/style.ads ada/styleg.ads \
- ada/styleg.adb ada/stylesw.ads ada/system.ads ada/s-crc32.ads \
- ada/s-exctab.ads ada/s-htable.ads ada/s-imenne.ads ada/s-memory.ads \
- ada/s-os_lib.ads ada/s-parame.ads ada/s-rident.ads ada/s-secsta.ads \
- ada/s-soflin.ads ada/s-stache.ads ada/s-stalib.ads ada/s-stoele.ads \
- ada/s-stoele.adb ada/s-string.ads ada/s-traent.ads ada/s-unstyp.ads \
- ada/s-utf_32.ads ada/s-wchcon.ads ada/table.ads ada/table.adb \
- ada/targparm.ads ada/tbuild.ads ada/tree_io.ads ada/ttypes.ads \
- ada/types.ads ada/uintp.ads ada/uintp.adb ada/uname.ads \
- ada/unchconv.ads ada/unchdeal.ads ada/urealp.ads ada/widechar.ads
+ ada/sem_res.ads ada/sem_type.ads ada/sem_util.ads ada/sem_util.adb \
+ ada/sem_warn.ads ada/sinfo.ads ada/sinfo.adb ada/sinput.ads \
+ ada/sinput.adb ada/snames.ads ada/snames.adb ada/stand.ads \
+ ada/stringt.ads ada/style.ads ada/styleg.ads ada/styleg.adb \
+ ada/stylesw.ads ada/system.ads ada/s-crc32.ads ada/s-exctab.ads \
+ ada/s-htable.ads ada/s-imenne.ads ada/s-memory.ads ada/s-os_lib.ads \
+ ada/s-parame.ads ada/s-rident.ads ada/s-secsta.ads ada/s-soflin.ads \
+ ada/s-stache.ads ada/s-stalib.ads ada/s-stoele.ads ada/s-stoele.adb \
+ ada/s-string.ads ada/s-traent.ads ada/s-unstyp.ads ada/s-utf_32.ads \
+ ada/s-wchcon.ads ada/table.ads ada/table.adb ada/targparm.ads \
+ ada/tbuild.ads ada/tree_io.ads ada/ttypes.ads ada/types.ads \
+ ada/uintp.ads ada/uintp.adb ada/uname.ads ada/unchconv.ads \
+ ada/unchdeal.ads ada/urealp.ads ada/widechar.ads
ada/sem_ch8.o : ada/ada.ads ada/a-except.ads ada/a-unccon.ads \
ada/a-uncdea.ads ada/alloc.ads ada/aspects.ads ada/atree.ads \
(thread : pthread_t;
cpusetsize : size_t;
cpuset : access cpu_set_t) return int;
- pragma Import (C, pthread_setaffinity_np, "pthread_setaffinity_np");
- pragma Weak_External (pthread_setaffinity_np);
- -- Use a weak symbol because this function may be available or not,
- -- depending on the version of the system.
+ pragma Import (C, pthread_setaffinity_np, "__gnat_pthread_setaffinity_np");
+ -- Use a wrapper because this function may be available or not, depending
+ -- on the version of the system.
function pthread_attr_setaffinity_np
(attr : access pthread_attr_t;
cpusetsize : size_t;
cpuset : access cpu_set_t) return int;
pragma Import (C, pthread_attr_setaffinity_np,
- "pthread_attr_setaffinity_np");
- pragma Weak_External (pthread_attr_setaffinity_np);
+ "__gnat_pthread_attr_setaffinity_np");
+ -- Use a wrapper because this function may be available or not, depending
+ -- on the version of the system.
private
(Attributes'Access, PTHREAD_CREATE_DETACHED);
pragma Assert (Result = 0);
- -- We were calling pthread_setaffinity_np (after thread creation but
- -- before thread activation) to set the affinity but it was not
- -- behaving as expected. Now we set the required attributes for the
- -- creation of the thread, which is working correctly and it is
- -- more appropriate.
+ -- Set the required attributes for the creation of the thread
- if pthread_attr_setaffinity_np'Address = System.Null_Address then
+ -- Note: Previously, we called pthread_setaffinity_np (after thread
+ -- creation but before thread activation) to set the affinity but it was
+ -- not behaving as expected. Setting the required attributes for the
+ -- creation of the thread works correctly and it is more appropriate.
- -- Nothing to do with the affinities if no underlying support
-
- null;
-
- -- Handle pragma CPU
-
- elsif T.Common.Base_CPU /= System.Multiprocessors.Not_A_Specific_CPU then
+ if T.Common.Base_CPU /= System.Multiprocessors.Not_A_Specific_CPU then
declare
CPU_Set : aliased cpu_set_t := (bits => (others => False));
begin