Hi folks I did some license review of Xen. I found some problems. At least one part is undistributable as it stands. mini-os ======mini-os consists of parts with a MIT-style license, parts with GPL v2 and parts with a 4-clause BSD: | extras/mini-os/include/lib.h: BSD (4 clause) | extras/mini-os/include/lib.h: BSD (4 clause) | extras/mini-os/lib/printf.c: BSD (4 clause) | extras/mini-os/lib/math.c: BSD (4 clause) The 4-clause BSD license is considered incompatible with the GPL[1]. public headers =============All the public headers in xen/include/public are supposed to be licensed under a MIT-style license, however some files lists other licenses. | xen/include/public/arch-ia64/debug_op.h: GPL (v2 or later) (with incorrect FSF address) | xen/include/public/arch-ia64/hvm/memmap.h: GPL (v2 or later) (with incorrect FSF address) | xen/include/public/arch-ia64/hvm/save.h: GPL (v2 or later) (with incorrect FSF address) | xen/include/public/arch-ia64/sioemu.h: GPL (v2 or later) (with incorrect FSF address) | xen/include/public/mem_event.h: GPL (v2 or later) (with incorrect FSF address) | xen/include/public/xsm/flask_op.h: *No copyright* GPL (v2,) | xen/include/public/xsm/flask_op.h: *No copyright* GPL (v2,) Bastian [1]: http://en.wikipedia.org/wiki/BSD_licenses#4-clause_license_.28original_.22BSD_License.22.29 -- The joys of love made her human and the agonies of love destroyed her. -- Spock, "Requiem for Methuselah", stardate 5842.8 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Hello, Bastian Blank, le Sat 30 Apr 2011 15:54:22 +0200, a écrit :> mini-os > ======> mini-os consists of parts with a MIT-style license, parts with GPL v2 > and parts with a 4-clause BSD: > | extras/mini-os/include/lib.h: BSD (4 clause) > | extras/mini-os/include/lib.h: BSD (4 clause) > | extras/mini-os/lib/printf.c: BSD (4 clause) > | extras/mini-os/lib/math.c: BSD (4 clause) > > The 4-clause BSD license is considered incompatible with the GPL[1].> [1]: http://en.wikipedia.org/wiki/BSD_licenses#4-clause_license_.28original_.22BSD_License.22.29This refers to http://www.gnu.org/philosophy/bsd.html for the actual issues, but I don''t see which part says how it is incompatible with GPL. That being said, this same page says that freebsd dropped the advertising clause from their own code, so I guess we can simply update to a newer version. Concerning include/lib.h, almost everything inside #ifdef HAVE_LIBC is mine, and I''m happy to drop the advertising clause on that part of the code, the rest inside HAVE_LIBC is very minor and probably doesn''t pose IP issues. What is outside HAVE_LIBC can probably be fetched from freebsd without the advertising clause. Samuel _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
On 30/04/2011 14:54, "Bastian Blank" <bastian@waldi.eu.org> wrote:> Hi folks > > I did some license review of Xen. I found some problems. At least one > part is undistributable as it stands. > > mini-os > ======> mini-os consists of parts with a MIT-style license, parts with GPL v2 > and parts with a 4-clause BSD: > | extras/mini-os/include/lib.h: BSD (4 clause) > | extras/mini-os/include/lib.h: BSD (4 clause) > | extras/mini-os/lib/printf.c: BSD (4 clause) > | extras/mini-os/lib/math.c: BSD (4 clause) > > The 4-clause BSD license is considered incompatible with the GPL[1].Samuel already replied regarding these, and he is a maintainer of mini-os so I''ll leave it to him. My opinion is that the files should preferably be updated if that allows us to license under modified BSD license. The modified license is widely agreed to be GPL compatible, whereas the old obnoxious advertising clause is definitely not.> public headers > =============> All the public headers in xen/include/public are supposed to be licensed > under a MIT-style license, however some files lists other licenses. > > | xen/include/public/arch-ia64/debug_op.h: GPL (v2 or later) (with incorrect > FSF address) > | xen/include/public/arch-ia64/hvm/memmap.h: GPL (v2 or later) (with incorrect > FSF address) > | xen/include/public/arch-ia64/hvm/save.h: GPL (v2 or later) (with incorrect > FSF address) > | xen/include/public/arch-ia64/sioemu.h: GPL (v2 or later) (with incorrect FSF > address) > | xen/include/public/mem_event.h: GPL (v2 or later) (with incorrect FSF > address) > | xen/include/public/xsm/flask_op.h: *No copyright* GPL (v2,) > | xen/include/public/xsm/flask_op.h: *No copyright* GPL (v2,)The file include/public/COPYING *very clearly* states that all files in that directory are licensed under a most permissive MIT-style license. The GPL stanzas just confuse matters, are obviously unintentional, and I will delete them. I''ll add the MIT license text where it''s missing, while I''m at it. -- Keir> Bastian > > [1]: > http://en.wikipedia.org/wiki/BSD_licenses#4-clause_license_.28original_.22BSD_ > License.22.29_______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Changeset df1348e72390 actually completely replaced the freebsd printf implementation with the Linux printf implementation. Further changes are extremely minor and thus don''t pose IP issue. Fix the licence accordingly. Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org> diff -r 7745109e3c6e extras/mini-os/lib/printf.c --- a/extras/mini-os/lib/printf.c Wed Apr 27 13:36:15 2011 +0100 +++ b/extras/mini-os/lib/printf.c Sat Apr 30 17:27:24 2011 +0200 @@ -1,4 +1,4 @@ -/* +/* **************************************************************************** * (C) 2003 - Rolf Neugebauer - Intel Research Cambridge **************************************************************************** @@ -6,52 +6,45 @@ * File: printf.c * Author: Rolf Neugebauer (neugebar@dcs.gla.ac.uk) * Changes: Grzegorz Milos (gm281@cam.ac.uk) - * + * * Date: Aug 2003, Aug 2005 - * + * * Environment: Xen Minimal OS * Description: Library functions for printing - * (freebsd port, mainly sys/subr_prf.c) + * (Linux port, mainly lib/vsprintf.c) * **************************************************************************** + */ + +/* + * Copyright (C) 1991, 1992 Linus Torvalds + */ + +/* vsprintf.c -- Lars Wirzenius & Linus Torvalds. */ +/* + * Wirzenius wrote this portably, Torvalds fucked it up :-) + */ + +/* + * Fri Jul 13 2001 Crutcher Dunnavant <crutcher+kernel@datastacks.com> + * - changed to provide snprintf and vsnprintf functions + * So Feb 1 16:51:32 CET 2004 Juergen Quade <quade@hsnr.de> + * - scnprintf and vscnprintf * - *- - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'''' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: src/sys/libkern/divdi3.c,v 1.6 1999/08/28 00:46:31 peter Exp $ + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #if !defined HAVE_LIBC _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Samuel Thibault
2011-Apr-30 16:10 UTC
[Xen-devel] [PATCH] mini-os: lib/math.c: import FreeBSD 8 functions
Import lib/math.c functions (and thus licence) from FreeBSD 8, and re-apply a few of our changes. Whitespaces left aside, this leads to almost no source change except s/int64_t/quad_t/ and s/uint64_t/u_quad_t/. Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org> diff -r 7745109e3c6e extras/mini-os/lib/math.c --- a/extras/mini-os/lib/math.c Wed Apr 27 13:36:15 2011 +0100 +++ b/extras/mini-os/lib/math.c Sat Apr 30 18:06:08 2011 +0200 @@ -13,10 +13,6 @@ * Description: Library functions for 64bit arith and other * from freebsd, files in sys/libkern/ (qdivrem.c, etc) * - **************************************************************************** - * $Id: c-insert.c,v 1.7 2002/11/08 16:04:34 rn Exp $ - **************************************************************************** - *- * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. * @@ -32,10 +28,6 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. @@ -52,7 +44,6 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/libkern/divdi3.c,v 1.6 1999/08/28 00:46:31 peter Exp $ */ #include <mini-os/types.h> @@ -63,49 +54,62 @@ * assembler functions. */ #if !defined(__ia64__) +/* XXX RN: Yuck hardcoded endianess :) */ +#define _QUAD_HIGHWORD 1 +#define _QUAD_LOWWORD 0 + +/* + * From + * @(#)quad.h 8.1 (Berkeley) 6/4/93 + */ + /* * Depending on the desired operation, we view a `long long'' (aka quad_t) in * one or more of the following formats. */ union uu { - int64_t q; /* as a (signed) quad */ - int64_t uq; /* as an unsigned quad */ - int32_t sl[2]; /* as two signed ints */ - uint32_t ul[2]; /* as two unsigned ints */ + quad_t q; /* as a (signed) quad */ + quad_t uq; /* as an unsigned quad */ + int32_t sl[2]; /* as two signed longs */ + uint32_t ul[2]; /* as two unsigned longs */ }; -/* XXX RN: Yuck hardcoded endianess :) */ -#define _QUAD_HIGHWORD 1 -#define _QUAD_LOWWORD 0 + /* * Define high and low longwords. */ -#define H _QUAD_HIGHWORD -#define L _QUAD_LOWWORD +#define H _QUAD_HIGHWORD +#define L _QUAD_LOWWORD /* - * Total number of bits in a quad_t and in the pieces that make it up. + * Total number of bits in an quad_t and in the pieces that make it up. * These are used for shifting, and also below for halfword extraction * and assembly. */ #ifndef HAVE_LIBC #define CHAR_BIT 8 /* number of bits in a char */ #endif -#define QUAD_BITS (sizeof(int64_t) * CHAR_BIT) -#define LONG_BITS (sizeof(int32_t) * CHAR_BIT) -#define HALF_BITS (sizeof(int32_t) * CHAR_BIT / 2) +#define QUAD_BITS (sizeof(quad_t) * CHAR_BIT) +#define LONG_BITS (sizeof(int32_t) * CHAR_BIT) +#define HALF_BITS (sizeof(int32_t) * CHAR_BIT / 2) /* - * Extract high and low shortwords from intword, and move low shortword of - * intword to upper half of int32_t, i.e., produce the upper intword of - * ((quad_t)(x) << (number_of_bits_in_int/2)). (`x'' must actually be uint32_t.) + * Extract high and low shortwords from longword, and move low shortword of + * longword to upper half of int32_t, i.e., produce the upper longword of + * ((quad_t)(x) << (number_of_bits_in_long/2)). (`x'' must actually be uint32_t.) * - * These are used in the multiply code, to split a intword into upper + * These are used in the multiply code, to split a longword into upper * and lower halves, and to reassemble a product as a quad_t, shifted left * (sizeof(int32_t)*CHAR_BIT/2). */ -#define HHALF(x) ((x) >> HALF_BITS) -#define LHALF(x) ((x) & ((1UL << HALF_BITS) - 1)) -#define LHUP(x) ((x) << HALF_BITS) +#define HHALF(x) ((x) >> HALF_BITS) +#define LHALF(x) ((x) & ((1UL << HALF_BITS) - 1)) +#define LHUP(x) ((x) << HALF_BITS) + + +/* + * From + * qdivrem.c + */ /* * Multiprecision divide. This algorithm is from Knuth vol. 2 (2nd ed), @@ -119,7 +123,6 @@ /* select a type for digits in base B: */ typedef uint16_t digit; - /* * Shift p[0]..p[len] left `sh'' bits, ignoring any bits that * `fall out'' the left (there never will be any such anyway). @@ -143,8 +146,8 @@ * divisor are 4 `digits'' in this base (they are shorter if they have * leading zeros). */ -uint64_t -__qdivrem(uint64_t uq, uint64_t vq, uint64_t *arq) +u_quad_t +__qdivrem(u_quad_t uq, u_quad_t vq, u_quad_t *arq) { union uu tmp; digit *u, *v, *q; @@ -339,38 +342,51 @@ return (tmp.q); } +/* + * From + * divdi3.c + */ /* * Divide two signed quads. * ??? if -1/2 should produce -1 on this machine, this code is wrong */ -int64_t -__divdi3(int64_t a, int64_t b) +quad_t +__divdi3(quad_t a, quad_t b) { - uint64_t ua, ub, uq; + u_quad_t ua, ub, uq; int neg; if (a < 0) - ua = -(uint64_t)a, neg = 1; + ua = -(u_quad_t)a, neg = 1; else ua = a, neg = 0; if (b < 0) - ub = -(uint64_t)b, neg ^= 1; + ub = -(u_quad_t)b, neg ^= 1; else ub = b; - uq = __qdivrem(ua, ub, (uint64_t *)0); + uq = __qdivrem(ua, ub, (u_quad_t *)0); return (neg ? -uq : uq); } /* + * From + * udivdi3.c + */ + +/* * Divide two unsigned quads. */ -uint64_t -__udivdi3(uint64_t a, uint64_t b) +u_quad_t +__udivdi3(u_quad_t a, u_quad_t b) { - return (__qdivrem(a, b, (uint64_t *)0)); + return (__qdivrem(a, b, (u_quad_t *)0)); } +/* + * From + * umoddi3.c + */ /* * Return remainder after dividing two unsigned quads. @@ -378,13 +394,18 @@ u_quad_t __umoddi3(u_quad_t a, u_quad_t b) { - u_quad_t r; + u_quad_t r; - (void)__qdivrem(a, b, &r); - return (r); + (void)__qdivrem(a, b, &r); + return (r); } /* + * From + * moddi3.c + */ + +/* * Return remainder after dividing two signed quads. * * XXX _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Update the Linux stdio functions prototypes, and move them to a separate header, licenced under GPL2+. Import FreeBSD8 string functions prototypes, update licence. Drop kvec, of unsure source and useless anyway. Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org> --- This should need approval from Grzegorz Milos, author of some bits that I left in the bsd-3-licenced lib.h, the rest is either mine or from people employed by Citrix (Stefano, Diego, Steven). diff -r 7745109e3c6e extras/mini-os/include/lib-gpl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/extras/mini-os/include/lib-gpl.h Sat Apr 30 18:34:07 2011 +0200 @@ -0,0 +1,59 @@ +/* -*- Mode:C; c-basic-offset:4; tab-width:4 -*- + **************************************************************************** + * (C) 2003 - Rolf Neugebauer - Intel Research Cambridge + **************************************************************************** + * + * File: lib.h + * Author: Rolf Neugebauer (neugebar@dcs.gla.ac.uk) + * Changes: + * + * Date: Aug 2003 + * + * Environment: Xen Minimal OS + * Description: Random useful library functions, from Linux'' + * include/linux/kernel.h + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef _LIB_GPL_H_ +#define _LIB_GPL_H_ + +#ifndef HAVE_LIBC +/* printing */ +extern unsigned long simple_strtoul(const char *,char **,unsigned int); +extern long simple_strtol(const char *,char **,unsigned int); +extern unsigned long long simple_strtoull(const char *,char **,unsigned int); +extern long long simple_strtoll(const char *,char **,unsigned int); + +extern int sprintf(char * buf, const char * fmt, ...) + __attribute__ ((format (printf, 2, 3))); +extern int vsprintf(char *buf, const char *, va_list) + __attribute__ ((format (printf, 2, 0))); +extern int snprintf(char * buf, size_t size, const char * fmt, ...) + __attribute__ ((format (printf, 3, 4))); +extern int vsnprintf(char *buf, size_t size, const char *fmt, va_list args) + __attribute__ ((format (printf, 3, 0))); +extern int scnprintf(char * buf, size_t size, const char * fmt, ...) + __attribute__ ((format (printf, 3, 4))); +extern int vscnprintf(char *buf, size_t size, const char *fmt, va_list args) + __attribute__ ((format (printf, 3, 0))); +extern int sscanf(const char *, const char *, ...) + __attribute__ ((format (scanf, 2, 3))); +extern int vsscanf(const char *, const char *, va_list) + __attribute__ ((format (scanf, 2, 0))); +#endif + +#endif /* _LIB_GPL_H_ */ diff -r 7745109e3c6e extras/mini-os/include/lib.h --- a/extras/mini-os/include/lib.h Wed Apr 27 13:36:15 2011 +0100 +++ b/extras/mini-os/include/lib.h Sat Apr 30 18:34:07 2011 +0200 @@ -16,9 +16,8 @@ * $Id: h-insert.h,v 1.4 2002/11/08 16:03:55 rn Exp $ **************************************************************************** * - *- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -28,10 +27,6 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. @@ -48,8 +43,6 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)stdarg.h 8.1 (Berkeley) 6/10/93 - * $FreeBSD: src/sys/i386/include/stdarg.h,v 1.10 1999/08/28 00:44:26 peter Exp $ */ #ifndef _LIB_H_ @@ -64,42 +57,48 @@ #ifdef HAVE_LIBC #include <stdio.h> #else -/* printing */ -#define _p(_x) ((void *)(unsigned long)(_x)) -int vsnprintf(char *buf, size_t size, const char *fmt, va_list args); -int vscnprintf(char *buf, size_t size, const char *fmt, va_list args); -int snprintf(char * buf, size_t size, const char *fmt, ...); -int scnprintf(char * buf, size_t size, const char *fmt, ...); -int vsprintf(char *buf, const char *fmt, va_list args); -int sprintf(char * buf, const char *fmt, ...); -int vsscanf(const char * buf, const char * fmt, va_list args); -int sscanf(const char * buf, const char * fmt, ...); +#include <lib-gpl.h> #endif -long simple_strtol(const char *cp,char **endp,unsigned int base); -unsigned long simple_strtoul(const char *cp,char **endp,unsigned int base); -long long simple_strtoll(const char *cp,char **endp,unsigned int base); -unsigned long long simple_strtoull(const char *cp,char **endp,unsigned int base); - #ifdef HAVE_LIBC #include <string.h> #else /* string and memory manipulation */ -int memcmp(const void *cs, const void *ct, size_t count); -void *memcpy(void *dest, const void *src, size_t count); -int strncmp(const char *cs, const char *ct, size_t count); -int strcmp(const char *cs, const char *ct); -char *strcpy(char *dest, const char *src); -char *strncpy(char *dest, const char *src, size_t count); -void *memset(void *s,int c, size_t count); -size_t strnlen(const char *s, size_t count); -size_t strlen(const char *s); -char *strchr(const char *s, int c); -char *strrchr(const char *s, int c); -char *strstr(const char *s1, const char *s2); -char * strcat(char * dest, const char * src); -char *strdup(const char *s); + +/* + * From: + * @(#)libkern.h 8.1 (Berkeley) 6/10/93 + * $FreeBSD$ + */ +int memcmp(const void *b1, const void *b2, size_t len); + +char *strcat(char * __restrict, const char * __restrict); +int strcmp(const char *, const char *); +char *strcpy(char * __restrict, const char * __restrict); + +char *strdup(const char *__restrict); + +size_t strlen(const char *); + +int strncmp(const char *, const char *, size_t); +char *strncpy(char * __restrict, const char * __restrict, size_t); + +char *strstr(const char *, const char *); + +void *memset(void *, int, size_t); + +char *strchr(const char *p, int ch); +char *strrchr(const char *p, int ch); + +/* From: + * @(#)systm.h 8.7 (Berkeley) 3/29/95 + * $FreeBSD$ + */ +void *memcpy(void *to, const void *from, size_t len); + +size_t strnlen(const char *, size_t); #endif + #include <mini-os/console.h> #define RAND_MIX 2654435769U @@ -110,11 +109,6 @@ #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) -struct kvec { - void *iov_base; - size_t iov_len; -}; - #define ASSERT(x) \ do { \ if (!(x)) { \ _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Keir Fraser
2011-Apr-30 19:31 UTC
[Xen-devel] Re: [PATCH] mini-os: lib/math.c: import FreeBSD 8 functions
Should the license terms really be enumerated 1, 2, 4? -- Keir On 30/04/2011 17:10, "Samuel Thibault" <samuel.thibault@ens-lyon.org> wrote:> Import lib/math.c functions (and thus licence) from FreeBSD 8, > and re-apply a few of our changes. Whitespaces left aside, this > leads to almost no source change except s/int64_t/quad_t/ and > s/uint64_t/u_quad_t/. > > Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org> > > diff -r 7745109e3c6e extras/mini-os/lib/math.c > --- a/extras/mini-os/lib/math.c Wed Apr 27 13:36:15 2011 +0100 > +++ b/extras/mini-os/lib/math.c Sat Apr 30 18:06:08 2011 +0200 > @@ -13,10 +13,6 @@ > * Description: Library functions for 64bit arith and other > * from freebsd, files in sys/libkern/ (qdivrem.c, etc) > * > - **************************************************************************** > - * $Id: c-insert.c,v 1.7 2002/11/08 16:04:34 rn Exp $ > - **************************************************************************** > - *- > * Copyright (c) 1992, 1993 > * The Regents of the University of California. All rights reserved. > * > @@ -32,10 +28,6 @@ > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > - * 3. All advertising materials mentioning features or use of this software > - * must display the following acknowledgement: > - * This product includes software developed by the University of > - * California, Berkeley and its contributors. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > @@ -52,7 +44,6 @@ > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > - * $FreeBSD: src/sys/libkern/divdi3.c,v 1.6 1999/08/28 00:46:31 peter Exp $ > */ > > #include <mini-os/types.h> > @@ -63,49 +54,62 @@ > * assembler functions. */ > #if !defined(__ia64__) > > +/* XXX RN: Yuck hardcoded endianess :) */ > +#define _QUAD_HIGHWORD 1 > +#define _QUAD_LOWWORD 0 > + > +/* > + * From > + * @(#)quad.h 8.1 (Berkeley) 6/4/93 > + */ > + > /* > * Depending on the desired operation, we view a `long long'' (aka quad_t) in > * one or more of the following formats. > */ > union uu { > - int64_t q; /* as a (signed) quad */ > - int64_t uq; /* as an unsigned quad */ > - int32_t sl[2]; /* as two signed ints */ > - uint32_t ul[2]; /* as two unsigned ints */ > + quad_t q; /* as a (signed) quad */ > + quad_t uq; /* as an unsigned quad */ > + int32_t sl[2]; /* as two signed longs */ > + uint32_t ul[2]; /* as two unsigned longs */ > }; > -/* XXX RN: Yuck hardcoded endianess :) */ > -#define _QUAD_HIGHWORD 1 > -#define _QUAD_LOWWORD 0 > + > /* > * Define high and low longwords. > */ > -#define H _QUAD_HIGHWORD > -#define L _QUAD_LOWWORD > +#define H _QUAD_HIGHWORD > +#define L _QUAD_LOWWORD > > /* > - * Total number of bits in a quad_t and in the pieces that make it up. > + * Total number of bits in an quad_t and in the pieces that make it up. > * These are used for shifting, and also below for halfword extraction > * and assembly. > */ > #ifndef HAVE_LIBC > #define CHAR_BIT 8 /* number of bits in a char */ > #endif > -#define QUAD_BITS (sizeof(int64_t) * CHAR_BIT) > -#define LONG_BITS (sizeof(int32_t) * CHAR_BIT) > -#define HALF_BITS (sizeof(int32_t) * CHAR_BIT / 2) > +#define QUAD_BITS (sizeof(quad_t) * CHAR_BIT) > +#define LONG_BITS (sizeof(int32_t) * CHAR_BIT) > +#define HALF_BITS (sizeof(int32_t) * CHAR_BIT / 2) > > /* > - * Extract high and low shortwords from intword, and move low shortword of > - * intword to upper half of int32_t, i.e., produce the upper intword of > - * ((quad_t)(x) << (number_of_bits_in_int/2)). (`x'' must actually be > uint32_t.) > + * Extract high and low shortwords from longword, and move low shortword of > + * longword to upper half of int32_t, i.e., produce the upper longword of > + * ((quad_t)(x) << (number_of_bits_in_long/2)). (`x'' must actually be > uint32_t.) > * > - * These are used in the multiply code, to split a intword into upper > + * These are used in the multiply code, to split a longword into upper > * and lower halves, and to reassemble a product as a quad_t, shifted left > * (sizeof(int32_t)*CHAR_BIT/2). > */ > -#define HHALF(x) ((x) >> HALF_BITS) > -#define LHALF(x) ((x) & ((1UL << HALF_BITS) - 1)) > -#define LHUP(x) ((x) << HALF_BITS) > +#define HHALF(x) ((x) >> HALF_BITS) > +#define LHALF(x) ((x) & ((1UL << HALF_BITS) - 1)) > +#define LHUP(x) ((x) << HALF_BITS) > + > + > +/* > + * From > + * qdivrem.c > + */ > > /* > * Multiprecision divide. This algorithm is from Knuth vol. 2 (2nd ed), > @@ -119,7 +123,6 @@ > /* select a type for digits in base B: */ > typedef uint16_t digit; > > - > /* > * Shift p[0]..p[len] left `sh'' bits, ignoring any bits that > * `fall out'' the left (there never will be any such anyway). > @@ -143,8 +146,8 @@ > * divisor are 4 `digits'' in this base (they are shorter if they have > * leading zeros). > */ > -uint64_t > -__qdivrem(uint64_t uq, uint64_t vq, uint64_t *arq) > +u_quad_t > +__qdivrem(u_quad_t uq, u_quad_t vq, u_quad_t *arq) > { > union uu tmp; > digit *u, *v, *q; > @@ -339,38 +342,51 @@ > return (tmp.q); > } > > +/* > + * From > + * divdi3.c > + */ > > /* > * Divide two signed quads. > * ??? if -1/2 should produce -1 on this machine, this code is wrong > */ > -int64_t > -__divdi3(int64_t a, int64_t b) > +quad_t > +__divdi3(quad_t a, quad_t b) > { > - uint64_t ua, ub, uq; > + u_quad_t ua, ub, uq; > int neg; > > if (a < 0) > - ua = -(uint64_t)a, neg = 1; > + ua = -(u_quad_t)a, neg = 1; > else > ua = a, neg = 0; > if (b < 0) > - ub = -(uint64_t)b, neg ^= 1; > + ub = -(u_quad_t)b, neg ^= 1; > else > ub = b; > - uq = __qdivrem(ua, ub, (uint64_t *)0); > + uq = __qdivrem(ua, ub, (u_quad_t *)0); > return (neg ? -uq : uq); > } > > /* > + * From > + * udivdi3.c > + */ > + > +/* > * Divide two unsigned quads. > */ > -uint64_t > -__udivdi3(uint64_t a, uint64_t b) > +u_quad_t > +__udivdi3(u_quad_t a, u_quad_t b) > { > - return (__qdivrem(a, b, (uint64_t *)0)); > + return (__qdivrem(a, b, (u_quad_t *)0)); > } > > +/* > + * From > + * umoddi3.c > + */ > > /* > * Return remainder after dividing two unsigned quads. > @@ -378,13 +394,18 @@ > u_quad_t > __umoddi3(u_quad_t a, u_quad_t b) > { > - u_quad_t r; > + u_quad_t r; > > - (void)__qdivrem(a, b, &r); > - return (r); > + (void)__qdivrem(a, b, &r); > + return (r); > } > > /* > + * From > + * moddi3.c > + */ > + > +/* > * Return remainder after dividing two signed quads. > * > * XXX_______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Samuel Thibault
2011-Apr-30 22:57 UTC
[Xen-devel] Re: [PATCH] mini-os: lib/math.c: import FreeBSD 8 functions
Keir Fraser, le Sat 30 Apr 2011 20:31:58 +0100, a écrit :> Should the license terms really be enumerated 1, 2, 4?That''s how it appears in the kfreebsd source: they simply dropped the 3rd term. Samuel _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel