src.patch

rumcic, 01/15/2008 04:27 PM

Download (6.08 KB)

View differences:

src/lib/libc/stdlib/Makefile.inc 2008-01-15 16:24:27 +0100
8 8
MISRCS+=abort.c abs.c atexit.c atof.c atoi.c atol.c atoll.c bsearch.c calloc.c div.c \
9 9
	exit.c getenv.c getopt.c getopt_long.c getsubopt.c hcreate.c heapsort.c \
10 10
	imaxabs.c \
11
	labs.c ldiv.c llabs.c malloc.c merge.c putenv.c qsort.c radixsort.c rand.c \
12
	random.c reallocf.c realpath.c setenv.c strtod.c strtoimax.c strtol.c \
11
	labs.c ldiv.c lldiv.c llabs.c malloc.c merge.c putenv.c qsort.c radixsort.c \
12
	rand.c random.c reallocf.c realpath.c setenv.c strtod.c strtoimax.c strtol.c \
13 13
	strtoll.c strtonum.c strtoq.c strtoul.c strtoull.c strtoumax.c \
14 14
	strtouq.c system.c tdelete.c tfind.c tsearch.c twalk.c
15 15

  
......
22 22
MAN+=	abort.3 abs.3 alloca.3 atexit.3 atof.3 atoi.3 atol.3 bsearch.3 \
23 23
	div.3 exit.3 getenv.3 getopt.3 getopt_long.3 getsubopt.3 hcreate.3 \
24 24
	imaxabs.3 \
25
	labs.3 ldiv.3 llabs.3 malloc.3 memory.3 qsort.3 radixsort.3 rand.3 random.3 \
26
	realpath.3 strtod.3 strtol.3 strtonum.3 strtoul.3 system.3 tsearch.3
25
	labs.3 ldiv.3 lldiv.3 llabs.3 malloc.3 memory.3 qsort.3 radixsort.3 rand.3 \
26
	random.3 realpath.3 strtod.3 strtol.3 strtonum.3 strtoul.3 system.3 tsearch.3
27 27

  
28 28
MLINKS+=atol.3 atoll.3
29 29
MLINKS+=exit.3 _Exit.3
30
-- /dev/null	2008-01-15 16:02:39 +0100
30
++ src/lib/libc/stdlib/lldiv.3	2008-01-15 16:26:51 +0100
......
1
.\" Copyright (c) 2001 Mike Barcroft <mike@FreeBSD.org>
2
.\" All rights reserved.
3
.\"
4
.\" Redistribution and use in source and binary forms, with or without
5
.\" modification, are permitted provided that the following conditions
6
.\" are met:
7
.\" 1. Redistributions of source code must retain the above copyright
8
.\"    notice, this list of conditions and the following disclaimer.
9
.\" 2. Redistributions in binary form must reproduce the above copyright
10
.\"    notice, this list of conditions and the following disclaimer in the
11
.\"    documentation and/or other materials provided with the distribution.
12
.\"
13
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16
.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23
.\" SUCH DAMAGE.
24
.\"
25
.\" $FreeBSD: src/lib/libc/stdlib/lldiv.3,v 1.2 2001/11/21 16:19:50 ru Exp $
26
.\"
27
.Dd November 14, 2001
28
.Dt LLDIV 3
29
.Os
30
.Sh NAME
31
.Nm lldiv
32
.Nd returns quotient and remainder
33
.Sh LIBRARY
34
.Lb libc
35
.Sh SYNOPSIS
36
.In stdlib.h
37
.Ft lldiv_t
38
.Fn lldiv "long long numer" "long long denom"
39
.Sh DESCRIPTION
40
The
41
.Fn lldiv
42
function computes the value of
43
.Fa numer
44
divided by
45
.Fa denom
46
and returns the stored result in the form of the
47
.Vt lldiv_t
48
type.
49
.Pp
50
The
51
.Vt lldiv_t
52
type is defined as:
53
.Bd -literal -offset indent
54
typedef struct {
55
	long long quot; /* Quotient. */
56
	long long rem;  /* Remainder. */
57
} lldiv_t;
58
.Ed
59
.Sh SEE ALSO
60
.Xr div 3 ,
61
.Xr imaxdiv 3 ,
62
.Xr ldiv 3 ,
63
.Xr math 3
64
.Sh STANDARDS
65
The
66
.Fn lldiv
67
function conforms to
68
.St -isoC-99 .
69
.Sh HISTORY
70
The
71
.Fn lldiv
72
function first appeared in
73
.Fx 5.0 .
......
0
-- /dev/null	2008-01-15 16:02:39 +0100
74
++ src/lib/libc/stdlib/lldiv.c	2008-01-15 16:28:49 +0100
......
1
/*-
2
 * Copyright (c) 2001 Mike Barcroft <mike@FreeBSD.org>
3
 * All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 * 1. Redistributions of source code must retain the above copyright
9
 *    notice, this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright
11
 *    notice, this list of conditions and the following disclaimer in the
12
 *    documentation and/or other materials provided with the distribution.
13
 *
14
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24
 * SUCH DAMAGE.
25
 *
26
 * $FreeBSD: src/lib/libc/stdlib/lldiv.c,v 1.1 2001/11/15 02:05:03 mike Exp $
27
 */
28

  
29
#include <stdlib.h>		/* lldiv_t */
30

  
31
lldiv_t
32
lldiv(long long numer, long long denom)
33
{
34
	lldiv_t retval;
35
	
36
	/* see div.c for comments */
37

  
38
	retval.quot = numer / denom;
39
	retval.rem = numer % denom;
40
	if (numer >= 0 && retval.rem < 0) {
41
		retval.quot++;
42
		retval.rem -= denom;
43
	}
44
	return (retval);
45
}
......
0
-- src/include/stdlib.h.orig	2007-12-02 18:08:33 +0100
46
++ src/include/stdlib.h	2008-01-15 16:00:42 +0100
......
67 67
	long rem;		/* remainder */
68 68
} ldiv_t;
69 69

  
70
#if __ISO_C_VISIBLE >= 1999
71
typedef struct {
72
        long long quot;
73
        long long rem;
74
} lldiv_t;
75
#endif
76

  
70 77
#ifndef NULL
71 78
#define	NULL	0
72 79
#endif
......
96 103
char	*getenv(const char *);
97 104
long	 labs(long) __pure2;
98 105
ldiv_t	 ldiv(long, long) __pure2;
106
#if __ISO_C_VISIBLE >= 1999
107
lldiv_t	 lldiv(long long, long long) __pure2;
108
#endif
99 109
void	*malloc(size_t);
100 110
void	 qsort(void *, size_t, size_t, int(*)(const void *, const void *));
101 111
int	 rand(void);