On 10/14/2013 2:22 AM, Sebastian Huber wrote: > Hello Joel, > > I would provide a super set of the FreeBSD and Linux APIs for RTEMS and use a > clean implementation. In case of conflicts I would use the Linux API. Its > just managing bits.
OK. I will try to post something today or tomorrow. > On 2013-10-11 23:06, Joel Sherrill wrote: >> Hi >> >> We are finishing up a proposal for pthread affinity APIs. We >> think we should follow the Linux API but have our own >> implementation. I am trying to use the FreeBSD cpu set code >> with minimal ifdefs, but there are differences which are >> adding up to the point where I have a problem. Do I put in >> lots of ifdef's? Or just create our own version using >> the BSD version as inspiration and code fragements? >> >> The first difference is Linux uses cpu_set_t while >> FreeBSD uses cpuset_t. This can be accounted for with >> a typedef. A global search and replace or using ifdefs >> will result in a file with lots of changes. Assume a >> typedef is OK since it minimizes impact of that. >> >> Then you have supporting macros. The following summarizes >> the similarities and differences. >> >> These macros appear to be the same on Linux and FreeBSD. >> >> void CPU_ZERO(cpu_set_t *set); >> void CPU_SET(int cpu, cpu_set_t *set); >> void CPU_CLR(int cpu, cpu_set_t *set); >> int CPU_ISSET(int cpu, cpu_set_t *set); >> >> For comparing sets, Linux has CPU_EQUAL while BSD has CPU_CMP. >> The signature is the same so a renaming macro would address this. >> >> int CPU_EQUAL(cpu_set_t *set1, cpu_set_t *set2); >> >> FreeBSD has these extra: >> >> void CPU_FILL(cpu_set_t *set) >> bool CPU_EMPTY(cpu_set_t *set) /* is empty? */ >> bool CPU_SUBSET(cpu_set_t *p,cpu_set_t *c) /* is c a subset of p? */ >> bool CPU_OVERLAP(cpu_set_t *p,cpu_set_t *c) /* do c and p overlap? */ >> >> And these differ between FreeBSD and Linux. The Linux API has three >> parameters and is performs bitwise operations on the two sources >> and puts the result in destination. FreeBSD has an "|=" or "&=" >> and takes destination and the set to operate with. This is the >> Linux API. Just drop a parameter to get FreeBSD but that makes >> them incompatible. >> >> void CPU_AND(cpu_set_t *destset, >> cpu_set_t *srcset1, cpu_set_t *srcset2); >> void CPU_OR(cpu_set_t *destset, >> cpu_set_t *srcset1, cpu_set_t *srcset2); >> void CPU_XOR(cpu_set_t *destset, >> cpu_set_t *srcset1, cpu_set_t *srcset2); >> >> FreeBSD also has NAND. >> >> Comments, suggestions, thoughts welcomed. >> >> > > -- Joel Sherrill, Ph.D. Director of Research & Development joel.sherr...@oarcorp.com On-Line Applications Research Ask me about RTEMS: a free RTOS Huntsville AL 35805 Support Available (256) 722-9985 _______________________________________________ rtems-devel mailing list rtems-devel@rtems.org http://www.rtems.org/mailman/listinfo/rtems-devel