summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/uclibc/uclibc-git/uclibc_scheduler_update.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-core/uclibc/uclibc-git/uclibc_scheduler_update.patch')
-rw-r--r--meta/recipes-core/uclibc/uclibc-git/uclibc_scheduler_update.patch455
1 files changed, 455 insertions, 0 deletions
diff --git a/meta/recipes-core/uclibc/uclibc-git/uclibc_scheduler_update.patch b/meta/recipes-core/uclibc/uclibc-git/uclibc_scheduler_update.patch
new file mode 100644
index 0000000000..78401bd2ad
--- /dev/null
+++ b/meta/recipes-core/uclibc/uclibc-git/uclibc_scheduler_update.patch
@@ -0,0 +1,455 @@
1From 2becc16ecbef71c496644d9dc6cbd7383d7cdca3 Mon Sep 17 00:00:00 2001
2From: Henning Heinold <heinold@inf.fu-berlin.de>
3Date: Sat, 4 Jun 2011 21:21:41 +0200
4Subject: [PATCH 1/2] libc: updates the linux scheduler functions, most stuff
5 was taken from the eglibc
6
7
8Signed-off-by: Henning Heinold <heinold@inf.fu-berlin.de>
9---
10 include/sched.h | 52 ++++++++++++----
11 libc/sysdeps/linux/common/Makefile.in | 4 +-
12 libc/sysdeps/linux/common/bits/sched.h | 96 +++++++++++++++++++++++-----
13 libc/sysdeps/linux/common/sched_cpualloc.c | 27 ++++++++
14 libc/sysdeps/linux/common/sched_cpucount.c | 60 +++++++++++++++++
15 libc/sysdeps/linux/common/sched_cpufree.c | 27 ++++++++
16 libc/sysdeps/linux/common/sched_getcpu.c | 37 +++++++++++
17 libc/sysdeps/linux/common/unshare.c | 12 ++++
18 8 files changed, 286 insertions(+), 29 deletions(-)
19 create mode 100644 libc/sysdeps/linux/common/sched_cpualloc.c
20 create mode 100644 libc/sysdeps/linux/common/sched_cpucount.c
21 create mode 100644 libc/sysdeps/linux/common/sched_cpufree.c
22 create mode 100644 libc/sysdeps/linux/common/sched_getcpu.c
23 create mode 100644 libc/sysdeps/linux/common/unshare.c
24
25diff --git a/include/sched.h b/include/sched.h
26index 0d110c3..e265b84 100644
27--- a/include/sched.h
28+++ b/include/sched.h
29@@ -1,5 +1,5 @@
30 /* Definitions for POSIX 1003.1b-1993 (aka POSIX.4) scheduling interface.
31- Copyright (C) 1996,1997,1999,2001-2003,2004 Free Software Foundation, Inc.
32+ Copyright (C) 1996,1997,1999,2001-2004,2007 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
34
35 The GNU C Library is free software; you can redistribute it and/or
36@@ -25,6 +25,9 @@
37 /* Get type definitions. */
38 #include <bits/types.h>
39
40+#define __need_size_t
41+#include <stddef.h>
42+
43 #define __need_timespec
44 #include <time.h>
45
46@@ -65,11 +68,42 @@ extern int sched_rr_get_interval (__pid_t __pid, struct timespec *__t) __THROW;
47
48 #if defined __USE_GNU && defined __UCLIBC_LINUX_SPECIFIC__
49 /* Access macros for `cpu_set'. */
50-#define CPU_SETSIZE __CPU_SETSIZE
51-#define CPU_SET(cpu, cpusetp) __CPU_SET (cpu, cpusetp)
52-#define CPU_CLR(cpu, cpusetp) __CPU_CLR (cpu, cpusetp)
53-#define CPU_ISSET(cpu, cpusetp) __CPU_ISSET (cpu, cpusetp)
54-#define CPU_ZERO(cpusetp) __CPU_ZERO (cpusetp)
55+# define CPU_SETSIZE __CPU_SETSIZE
56+# define CPU_SET(cpu, cpusetp) __CPU_SET_S (cpu, sizeof (cpu_set_t), cpusetp)
57+# define CPU_CLR(cpu, cpusetp) __CPU_CLR_S (cpu, sizeof (cpu_set_t), cpusetp)
58+# define CPU_ISSET(cpu, cpusetp) __CPU_ISSET_S (cpu, sizeof (cpu_set_t), \
59+ cpusetp)
60+# define CPU_ZERO(cpusetp) __CPU_ZERO_S (sizeof (cpu_set_t), cpusetp)
61+# define CPU_COUNT(cpusetp) __CPU_COUNT_S (sizeof (cpu_set_t), cpusetp)
62+
63+# define CPU_SET_S(cpu, setsize, cpusetp) __CPU_SET_S (cpu, setsize, cpusetp)
64+# define CPU_CLR_S(cpu, setsize, cpusetp) __CPU_CLR_S (cpu, setsize, cpusetp)
65+# define CPU_ISSET_S(cpu, setsize, cpusetp) __CPU_ISSET_S (cpu, setsize, \
66+ cpusetp)
67+# define CPU_ZERO_S(setsize, cpusetp) __CPU_ZERO_S (setsize, cpusetp)
68+# define CPU_COUNT_S(setsize, cpusetp) __CPU_COUNT_S (setsize, cpusetp)
69+
70+# define CPU_EQUAL(cpusetp1, cpusetp2) \
71+ __CPU_EQUAL_S (sizeof (cpu_set_t), cpusetp1, cpusetp2)
72+# define CPU_EQUAL_S(setsize, cpusetp1, cpusetp2) \
73+ __CPU_EQUAL_S (setsize, cpusetp1, cpusetp2)
74+
75+# define CPU_AND(destset, srcset1, srcset2) \
76+ __CPU_OP_S (sizeof (cpu_set_t), destset, srcset1, srcset2, &)
77+# define CPU_OR(destset, srcset1, srcset2) \
78+ __CPU_OP_S (sizeof (cpu_set_t), destset, srcset1, srcset2, |)
79+# define CPU_XOR(destset, srcset1, srcset2) \
80+ __CPU_OP_S (sizeof (cpu_set_t), destset, srcset1, srcset2, ^)
81+# define CPU_AND_S(setsize, destset, srcset1, srcset2) \
82+ __CPU_OP_S (setsize, destset, srcset1, srcset2, &)
83+# define CPU_OR_S(setsize, destset, srcset1, srcset2) \
84+ __CPU_OP_S (setsize, destset, srcset1, srcset2, |)
85+# define CPU_XOR_S(setsize, destset, srcset1, srcset2) \
86+ __CPU_OP_S (setsize, destset, srcset1, srcset2, ^)
87+
88+# define CPU_ALLOC_SIZE(count) __CPU_ALLOC_SIZE (count)
89+# define CPU_ALLOC(count) __CPU_ALLOC (count)
90+# define CPU_FREE(cpuset) __CPU_FREE (cpuset)
91
92
93 /* Set the CPU affinity for a task */
94@@ -79,12 +113,6 @@ extern int sched_setaffinity (__pid_t __pid, size_t __cpusetsize,
95 /* Get the CPU affinity for a task */
96 extern int sched_getaffinity (__pid_t __pid, size_t __cpusetsize,
97 cpu_set_t *__cpuset) __THROW;
98-
99-extern int __clone (int (*__fn) (void *__arg), void *__child_stack,
100- int __flags, void *__arg, ...);
101-extern int __clone2 (int (*__fn) (void *__arg), void *__child_stack_base,
102- size_t __child_stack_size, int __flags, void *__arg, ...);
103-
104 #endif
105
106 __END_DECLS
107diff --git a/libc/sysdeps/linux/common/Makefile.in b/libc/sysdeps/linux/common/Makefile.in
108index 8f936ff..cb8c153 100644
109--- a/libc/sysdeps/linux/common/Makefile.in
110+++ b/libc/sysdeps/linux/common/Makefile.in
111@@ -22,9 +22,11 @@ CSRC-$(UCLIBC_LINUX_SPECIFIC) += capget.c capset.c inotify.c ioperm.c iopl.c \
112 modify_ldt.c pipe2.c personality.c ppoll.c prctl.c \
113 readahead.c reboot.c \
114 remap_file_pages.c sched_getaffinity.c sched_setaffinity.c \
115+ sched_cpualloc.c sched_cpucount.c sched_cpufree.c \
116 sendfile64.c sendfile.c setfsgid.c setfsuid.c setresuid.c \
117 splice.c vmsplice.c tee.c signalfd.c swapoff.c swapon.c \
118- sync_file_range.c sysctl.c sysinfo.c timerfd.c uselib.c vhangup.c
119+ sync_file_range.c sysctl.c sysinfo.c timerfd.c unshare.c \
120+ uselib.c vhangup.c
121 # NPTL needs these internally: madvise.c
122 CSRC-$(findstring y,$(UCLIBC_LINUX_SPECIFIC)$(UCLIBC_HAS_THREADS_NATIVE)) += madvise.c
123 ifeq ($(UCLIBC_HAS_THREADS_NATIVE),y)
124diff --git a/libc/sysdeps/linux/common/bits/sched.h b/libc/sysdeps/linux/common/bits/sched.h
125index b48a0c8..fea66a8 100644
126--- a/libc/sysdeps/linux/common/bits/sched.h
127+++ b/libc/sysdeps/linux/common/bits/sched.h
128@@ -1,6 +1,7 @@
129 /* Definitions of constants and data structure for POSIX 1003.1b-1993
130 scheduling interface.
131- Copyright (C) 1996-1999,2001-2003,2005,2006 Free Software Foundation, Inc.
132+ Copyright (C) 1996-1999,2001-2003,2005,2006,2007,2008
133+ Free Software Foundation, Inc.
134 This file is part of the GNU C Library.
135
136 The GNU C Library is free software; you can redistribute it and/or
137@@ -58,7 +59,13 @@
138 force CLONE_PTRACE on this clone. */
139 # define CLONE_CHILD_SETTID 0x01000000 /* Store TID in userlevel buffer in
140 the child. */
141-# define CLONE_STOPPED 0x02000000 /* Start in stopped state. */
142+# define CLONE_STOPPED 0x02000000 /* Start in stopped state. */
143+# define CLONE_NEWUTS 0x04000000 /* New utsname group. */
144+# define CLONE_NEWIPC 0x08000000 /* New ipcs. */
145+# define CLONE_NEWUSER 0x10000000 /* New user namespace. */
146+# define CLONE_NEWPID 0x20000000 /* New pid namespace. */
147+# define CLONE_NEWNET 0x40000000 /* New network namespace. */
148+# define CLONE_IO 0x80000000 /* Clone I/O context. */
149 #endif
150
151 /* The official definition. */
152@@ -74,10 +81,11 @@ __BEGIN_DECLS
153 extern int clone (int (*__fn) (void *__arg), void *__child_stack,
154 int __flags, void *__arg, ...) __THROW;
155
156-#if 0
157 /* Unshare the specified resources. */
158 extern int unshare (int __flags) __THROW;
159-#endif
160+
161+/* Get index of currently used CPU. */
162+extern int sched_getcpu (void) __THROW;
163 #endif
164
165 __END_DECLS
166@@ -102,7 +110,7 @@ struct __sched_param
167 # define __CPU_SETSIZE 1024
168 # define __NCPUBITS (8 * sizeof (__cpu_mask))
169
170-/* Type for array elements in 'cpu_set'. */
171+/* Type for array elements in 'cpu_set_t'. */
172 typedef unsigned long int __cpu_mask;
173
174 /* Basic access functions. */
175@@ -116,17 +124,73 @@ typedef struct
176 } cpu_set_t;
177
178 /* Access functions for CPU masks. */
179-# define __CPU_ZERO(cpusetp) \
180+# define __CPU_ZERO_S(setsize, cpusetp) \
181 do { \
182- unsigned int __i; \
183- cpu_set_t *__arr = (cpusetp); \
184- for (__i = 0; __i < sizeof (cpu_set_t) / sizeof (__cpu_mask); ++__i) \
185- __arr->__bits[__i] = 0; \
186+ size_t __i; \
187+ size_t __imax = (setsize) / sizeof (__cpu_mask); \
188+ __cpu_mask *__bits = (cpusetp)->__bits; \
189+ for (__i = 0; __i < __imax; ++__i) \
190+ __bits[__i] = 0; \
191 } while (0)
192-# define __CPU_SET(cpu, cpusetp) \
193- ((cpusetp)->__bits[__CPUELT (cpu)] |= __CPUMASK (cpu))
194-# define __CPU_CLR(cpu, cpusetp) \
195- ((cpusetp)->__bits[__CPUELT (cpu)] &= ~__CPUMASK (cpu))
196-# define __CPU_ISSET(cpu, cpusetp) \
197- (((cpusetp)->__bits[__CPUELT (cpu)] & __CPUMASK (cpu)) != 0)
198+# define __CPU_SET_S(cpu, setsize, cpusetp) \
199+ (__extension__ \
200+ ({ size_t __cpu = (cpu); \
201+ __cpu < 8 * (setsize) \
202+ ? (((__cpu_mask *) ((cpusetp)->__bits))[__CPUELT (__cpu)] \
203+ |= __CPUMASK (__cpu)) \
204+ : 0; }))
205+# define __CPU_CLR_S(cpu, setsize, cpusetp) \
206+ (__extension__ \
207+ ({ size_t __cpu = (cpu); \
208+ __cpu < 8 * (setsize) \
209+ ? (((__cpu_mask *) ((cpusetp)->__bits))[__CPUELT (__cpu)] \
210+ &= ~__CPUMASK (__cpu)) \
211+ : 0; }))
212+# define __CPU_ISSET_S(cpu, setsize, cpusetp) \
213+ (__extension__ \
214+ ({ size_t __cpu = (cpu); \
215+ __cpu < 8 * (setsize) \
216+ ? ((((__cpu_mask *) ((cpusetp)->__bits))[__CPUELT (__cpu)] \
217+ & __CPUMASK (__cpu))) != 0 \
218+ : 0; }))
219+
220+# define __CPU_COUNT_S(setsize, cpusetp) \
221+ __sched_cpucount (setsize, cpusetp)
222+
223+# define __CPU_EQUAL_S(setsize, cpusetp1, cpusetp2) \
224+ (__extension__ \
225+ ({ __cpu_mask *__arr1 = (cpusetp1)->__bits; \
226+ __cpu_mask *__arr2 = (cpusetp2)->__bits; \
227+ size_t __imax = (setsize) / sizeof (__cpu_mask); \
228+ size_t __i; \
229+ for (__i = 0; __i < __imax; ++__i) \
230+ if (__arr1[__i] != __arr2[__i]) \
231+ break; \
232+ __i == __imax; }))
233+
234+# define __CPU_OP_S(setsize, destset, srcset1, srcset2, op) \
235+ (__extension__ \
236+ ({ cpu_set_t *__dest = (destset); \
237+ __cpu_mask *__arr1 = (srcset1)->__bits; \
238+ __cpu_mask *__arr2 = (srcset2)->__bits; \
239+ size_t __imax = (setsize) / sizeof (__cpu_mask); \
240+ size_t __i; \
241+ for (__i = 0; __i < __imax; ++__i) \
242+ ((__cpu_mask *) __dest->__bits)[__i] = __arr1[__i] op __arr2[__i]; \
243+ __dest; }))
244+
245+# define __CPU_ALLOC_SIZE(count) \
246+ ((((count) + __NCPUBITS - 1) / __NCPUBITS) * sizeof (__cpu_mask))
247+# define __CPU_ALLOC(count) __sched_cpualloc (count)
248+# define __CPU_FREE(cpuset) __sched_cpufree (cpuset)
249+
250+__BEGIN_DECLS
251+
252+extern int __sched_cpucount (size_t __setsize, const cpu_set_t *__setp)
253+ __THROW;
254+extern cpu_set_t *__sched_cpualloc (size_t __count) __THROW __wur;
255+extern void __sched_cpufree (cpu_set_t *__set) __THROW;
256+
257+__END_DECLS
258+
259 #endif
260diff --git a/libc/sysdeps/linux/common/sched_cpualloc.c b/libc/sysdeps/linux/common/sched_cpualloc.c
261new file mode 100644
262index 0000000..2642a80
263--- /dev/null
264+++ b/libc/sysdeps/linux/common/sched_cpualloc.c
265@@ -0,0 +1,27 @@
266+/* Copyright (C) 2007 Free Software Foundation, Inc.
267+ This file is part of the GNU C Library.
268+
269+ The GNU C Library is free software; you can redistribute it and/or
270+ modify it under the terms of the GNU Lesser General Public
271+ License as published by the Free Software Foundation; either
272+ version 2.1 of the License, or (at your option) any later version.
273+
274+ The GNU C Library is distributed in the hope that it will be useful,
275+ but WITHOUT ANY WARRANTY; without even the implied warranty of
276+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
277+ Lesser General Public License for more details.
278+
279+ You should have received a copy of the GNU Lesser General Public
280+ License along with the GNU C Library; if not, write to the Free
281+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
282+ 02111-1307 USA. */
283+
284+#include <sched.h>
285+#include <stdlib.h>
286+
287+
288+cpu_set_t *
289+__sched_cpualloc (size_t count)
290+{
291+ return malloc (CPU_ALLOC_SIZE (count));
292+}
293diff --git a/libc/sysdeps/linux/common/sched_cpucount.c b/libc/sysdeps/linux/common/sched_cpucount.c
294new file mode 100644
295index 0000000..331c0b8
296--- /dev/null
297+++ b/libc/sysdeps/linux/common/sched_cpucount.c
298@@ -0,0 +1,60 @@
299+/* Copyright (C) 2007 Free Software Foundation, Inc.
300+ This file is part of the GNU C Library.
301+
302+ The GNU C Library is free software; you can redistribute it and/or
303+ modify it under the terms of the GNU Lesser General Public
304+ License as published by the Free Software Foundation; either
305+ version 2.1 of the License, or (at your option) any later version.
306+
307+ The GNU C Library is distributed in the hope that it will be useful,
308+ but WITHOUT ANY WARRANTY; without even the implied warranty of
309+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
310+ Lesser General Public License for more details.
311+
312+ You should have received a copy of the GNU Lesser General Public
313+ License along with the GNU C Library; if not, write to the Free
314+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
315+ 02111-1307 USA. */
316+
317+#include <limits.h>
318+#include <sched.h>
319+
320+
321+int
322+__sched_cpucount (size_t setsize, const cpu_set_t *setp)
323+{
324+ int s = 0;
325+ const __cpu_mask *p = setp->__bits;
326+ const __cpu_mask *end = &setp->__bits[setsize / sizeof (__cpu_mask)];
327+
328+ while (p < end)
329+ {
330+ __cpu_mask l = *p++;
331+
332+#ifdef POPCNT
333+ s += POPCNT (l);
334+#else
335+ if (l == 0)
336+ continue;
337+
338+# if LONG_BIT > 32
339+ l = (l & 0x5555555555555555ul) + ((l >> 1) & 0x5555555555555555ul);
340+ l = (l & 0x3333333333333333ul) + ((l >> 2) & 0x3333333333333333ul);
341+ l = (l & 0x0f0f0f0f0f0f0f0ful) + ((l >> 4) & 0x0f0f0f0f0f0f0f0ful);
342+ l = (l & 0x00ff00ff00ff00fful) + ((l >> 8) & 0x00ff00ff00ff00fful);
343+ l = (l & 0x0000ffff0000fffful) + ((l >> 16) & 0x0000ffff0000fffful);
344+ l = (l & 0x00000000fffffffful) + ((l >> 32) & 0x00000000fffffffful);
345+# else
346+ l = (l & 0x55555555ul) + ((l >> 1) & 0x55555555ul);
347+ l = (l & 0x33333333ul) + ((l >> 2) & 0x33333333ul);
348+ l = (l & 0x0f0f0f0ful) + ((l >> 4) & 0x0f0f0f0ful);
349+ l = (l & 0x00ff00fful) + ((l >> 8) & 0x00ff00fful);
350+ l = (l & 0x0000fffful) + ((l >> 16) & 0x0000fffful);
351+# endif
352+
353+ s += l;
354+#endif
355+ }
356+
357+ return s;
358+}
359diff --git a/libc/sysdeps/linux/common/sched_cpufree.c b/libc/sysdeps/linux/common/sched_cpufree.c
360new file mode 100644
361index 0000000..dd4c613
362--- /dev/null
363+++ b/libc/sysdeps/linux/common/sched_cpufree.c
364@@ -0,0 +1,27 @@
365+/* Copyright (C) 2007 Free Software Foundation, Inc.
366+ This file is part of the GNU C Library.
367+
368+ The GNU C Library is free software; you can redistribute it and/or
369+ modify it under the terms of the GNU Lesser General Public
370+ License as published by the Free Software Foundation; either
371+ version 2.1 of the License, or (at your option) any later version.
372+
373+ The GNU C Library is distributed in the hope that it will be useful,
374+ but WITHOUT ANY WARRANTY; without even the implied warranty of
375+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
376+ Lesser General Public License for more details.
377+
378+ You should have received a copy of the GNU Lesser General Public
379+ License along with the GNU C Library; if not, write to the Free
380+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
381+ 02111-1307 USA. */
382+
383+#include <sched.h>
384+#include <stdlib.h>
385+
386+
387+void
388+__sched_cpufree (cpu_set_t *set)
389+{
390+ free (set);
391+}
392diff --git a/libc/sysdeps/linux/common/sched_getcpu.c b/libc/sysdeps/linux/common/sched_getcpu.c
393new file mode 100644
394index 0000000..b193d65
395--- /dev/null
396+++ b/libc/sysdeps/linux/common/sched_getcpu.c
397@@ -0,0 +1,37 @@
398+/* Copyright (C) 2007 Free Software Foundation, Inc.
399+ This file is part of the GNU C Library.
400+
401+ The GNU C Library is free software; you can redistribute it and/or
402+ modify it under the terms of the GNU Lesser General Public
403+ License as published by the Free Software Foundation; either
404+ version 2.1 of the License, or (at your option) any later version.
405+
406+ The GNU C Library is distributed in the hope that it will be useful,
407+ but WITHOUT ANY WARRANTY; without even the implied warranty of
408+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
409+ Lesser General Public License for more details.
410+
411+ You should have received a copy of the GNU Lesser General Public
412+ License along with the GNU C Library; if not, write to the Free
413+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
414+ 02111-1307 USA. */
415+
416+#include <stdlib.h>
417+#include <errno.h>
418+#include <sched.h>
419+#include <sysdep.h>
420+
421+
422+int
423+sched_getcpu (void)
424+{
425+#ifdef __NR_getcpu
426+ unsigned int cpu;
427+ int r = INLINE_SYSCALL (getcpu, 3, &cpu, NULL, NULL);
428+
429+ return r == -1 ? r : cpu;
430+#else
431+ __set_errno (ENOSYS);
432+ return -1;
433+#endif
434+}
435diff --git a/libc/sysdeps/linux/common/unshare.c b/libc/sysdeps/linux/common/unshare.c
436new file mode 100644
437index 0000000..485bf88
438--- /dev/null
439+++ b/libc/sysdeps/linux/common/unshare.c
440@@ -0,0 +1,12 @@
441+/* vi: set sw=4 ts=4: */
442+/*
443+ * unshare() for uClibc
444+ *
445+ * Copyright (C) 2011 Henning Heinold <heinold@inf.fu-berlin.de>
446+ *
447+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
448+ */
449+
450+#include <sys/syscall.h>
451+#include <sched.h>
452+_syscall1(int, unshare, int, flags)
453--
4541.7.5.3
455