Skip to contentSkip to conversation

License problems

PATCH New Bastian Blank 3 participants 8 messages Apr 30, 2011

lore
Share & tools
lore
#0 lore raw

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

Signature · 2 lines
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
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw

Hello,

Quoted 4 lines · 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:

Quoted 8 lines
| 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.29

This 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

#2 lore raw
In reply to Bastian Blank
Quoted 9 lines · Bastian Blank

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:

Quoted 6 lines
| 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.

Quoted 5 lines

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.

Quoted 12 lines

| 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

Quoted 5 lines

Bastian

[1]:
http://en.wikipedia.org/wiki/BSD_licenses#4-clause_license_.28original_.22BSD_
License.22.29

#3 lore raw

PATCH 1/1 mini-os: Fix printf.c licence

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.

extras/mini-os/lib/printf.c +31 -38
diff -r 7745109e3c6e extras/mini-os/lib/printf.c
@@ -1,4 +1,4 @@
-/* 
+/*
  ****************************************************************************
  * (C) 2003 - Rolf Neugebauer - Intel Research Cambridge
  ****************************************************************************
@@ -6,52 +6,45 @@
  *        File: printf.c
  *      Author: Rolf Neugebauer ([email protected])
  *     Changes: Grzegorz Milos ([email protected]) 
- *              
+ *
  *        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 <[email protected]>
+ * - changed to provide snprintf and vsnprintf functions
+ * So Feb  1 16:51:32 CET 2004 Juergen Quade <[email protected]>
+ * - 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
#4 lore raw

PATCH 1/1 mini-os: lib/math.c: import FreeBSD 8 functions

In reply to Keir Fraser

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/.

extras/mini-os/lib/math.c +65 -44
diff -r 7745109e3c6e extras/mini-os/lib/math.c
@@ -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
#7 lore raw

PATCH 1/1 mini-os: fix lib.h licence

In reply to Keir Fraser

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.

---
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).

extras/mini-os/include/lib-gpl.h new file +59 -0
diff -r 7745109e3c6e extras/mini-os/include/lib-gpl.h
@@ -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 ([email protected])
+ *     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_ */
extras/mini-os/include/lib.h +37 -43

117 lines not on this page · raw message

#5 lore raw

Re: [PATCH] mini-os: lib/math.c: import FreeBSD 8 functions

In reply to Samuel Thibault

Should the license terms really be enumerated 1, 2, 4?

-- Keir

Quoted 227 lines · Samuel Thibault

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/.

diff -r 7745109e3c6e extras/mini-os/lib/math.c

extras/mini-os/lib/math.c Sat Apr 30 18:06:08 2011 +0200 renamed from extras/mini-os/lib/math.c Wed Apr 27 13:36:15 2011 +0100 +33 -29
@@ -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),

extras/mini-os/lib/math.c Sat Apr 30 18:06:08 2011 +0200 renamed from extras/mini-os/lib/math.c Wed Apr 27 13:36:15 2011 +0100 +10 -7
@@ -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)

extras/mini-os/lib/math.c Sat Apr 30 18:06:08 2011 +0200 renamed from extras/mini-os/lib/math.c Wed Apr 27 13:36:15 2011 +0100 +1 -1
-  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
+ */

extras/mini-os/lib/math.c Sat Apr 30 18:06:08 2011 +0200 renamed from extras/mini-os/lib/math.c Wed Apr 27 13:36:15 2011 +0100 +17 -6
+
+/*
  * 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
#6 lore raw

Re: [PATCH] mini-os: lib/math.c: import FreeBSD 8 functions

Quoted 1 line · 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