aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kabaev <kan@FreeBSD.org>2003-04-29 13:36:06 +0000
committerAlexander Kabaev <kan@FreeBSD.org>2003-04-29 13:36:06 +0000
commit104a9b7e3edbd88cdda0698c5c77a2ad6dafcc16 (patch)
tree9f5fdcd6775a2bfa21ddfc84568b82ecb2815a2b
parent5364715a0e35f79cb225534d58c3aa54dacfa18b (diff)
downloadsrc-104a9b7e3edbd88cdda0698c5c77a2ad6dafcc16.tar.gz
src-104a9b7e3edbd88cdda0698c5c77a2ad6dafcc16.zip
Deprecate machine/limits.h in favor of new sys/limits.h.
Change all in-tree consumers to include <sys/limits.h> Discussed on: standards@ Partially submitted by: Craig Rodrigues <rodrigc@attbi.com>
Notes
Notes: svn path=/head/; revision=114216
-rw-r--r--include/limits.h2
-rw-r--r--sys/alpha/include/limits.h68
-rw-r--r--sys/amd64/include/limits.h68
-rw-r--r--sys/amd64/isa/clock.c2
-rw-r--r--sys/arm/include/limits.h67
-rw-r--r--sys/cam/cam_ccb.h2
-rw-r--r--sys/cam/scsi/scsi_sa.c2
-rw-r--r--sys/compat/linux/linux_ipc.c3
-rw-r--r--sys/compat/linux/linux_misc.c3
-rw-r--r--sys/compat/linux/linux_socket.c3
-rw-r--r--sys/dev/atkbdc/atkbd.c3
-rw-r--r--sys/dev/atkbdc/psm.c2
-rw-r--r--sys/dev/eisa/eisaconf.c2
-rw-r--r--sys/dev/kbd/atkbd.c3
-rw-r--r--sys/dev/mca/mca_bus.c2
-rw-r--r--sys/dev/raidframe/rf_types.h2
-rw-r--r--sys/dev/ray/if_ray.c3
-rw-r--r--sys/dev/sio/sio.c2
-rw-r--r--sys/dev/sound/midi/midi.h2
-rw-r--r--sys/dev/syscons/scmouse.c2
-rw-r--r--sys/dev/usb/ukbd.c2
-rw-r--r--sys/fs/pseudofs/pseudofs_fileno.c3
-rw-r--r--sys/fs/smbfs/smbfs_vnops.c3
-rw-r--r--sys/geom/geom_dev.c2
-rw-r--r--sys/i386/include/limits.h67
-rw-r--r--sys/i386/isa/clock.c2
-rw-r--r--sys/ia64/include/limits.h69
-rw-r--r--sys/isa/atrtc.c2
-rw-r--r--sys/isa/psm.c2
-rw-r--r--sys/kern/kern_clock.c2
-rw-r--r--sys/kern/kern_descrip.c3
-rw-r--r--sys/kern/kern_lockf.c3
-rw-r--r--sys/kern/subr_scanf.c2
-rw-r--r--sys/kern/sys_generic.c3
-rw-r--r--sys/kern/uipc_socket.c2
-rw-r--r--sys/kern/vfs_aio.c3
-rw-r--r--sys/kern/vfs_default.c3
-rw-r--r--sys/kern/vfs_extattr.c2
-rw-r--r--sys/kern/vfs_syscalls.c2
-rw-r--r--sys/kern/vfs_vnops.c3
-rw-r--r--sys/libkern/quad.h2
-rw-r--r--sys/libkern/strtol.c2
-rw-r--r--sys/libkern/strtoq.c2
-rw-r--r--sys/libkern/strtoul.c2
-rw-r--r--sys/libkern/strtouq.c2
-rw-r--r--sys/netgraph/ng_base.c2
-rw-r--r--sys/netgraph/ng_ppp.c3
-rw-r--r--sys/netinet/in_pcb.c3
-rw-r--r--sys/nfsclient/nfs_lock.c3
-rw-r--r--sys/nfsclient/nfs_vfsops.c3
-rw-r--r--sys/pc98/cbus/clock.c2
-rw-r--r--sys/pc98/cbus/pckbd.c2
-rw-r--r--sys/pc98/cbus/pcrtc.c2
-rw-r--r--sys/pc98/cbus/sio.c2
-rw-r--r--sys/pc98/pc98/clock.c2
-rw-r--r--sys/pc98/pc98/pc98kbd.c2
-rw-r--r--sys/pc98/pc98/sio.c2
-rw-r--r--sys/powerpc/include/limits.h70
-rw-r--r--sys/sparc64/include/limits.h68
-rw-r--r--sys/sys/param.h2
-rw-r--r--sys/ufs/ffs/ffs_rawread.c2
-rw-r--r--sys/ufs/ffs/ffs_vnops.c3
-rw-r--r--sys/vm/vm_glue.c3
63 files changed, 87 insertions, 522 deletions
diff --git a/include/limits.h b/include/limits.h
index ca5edb21a5aa..3f770cc3408e 100644
--- a/include/limits.h
+++ b/include/limits.h
@@ -125,7 +125,7 @@
#define MB_LEN_MAX 6 /* 31-bit UTF-8 */
-#include <machine/limits.h>
+#include <sys/limits.h>
#if __POSIX_VISIBLE
#include <sys/syslimits.h>
diff --git a/sys/alpha/include/limits.h b/sys/alpha/include/limits.h
index d45e08aee5f2..cbbcf5926796 100644
--- a/sys/alpha/include/limits.h
+++ b/sys/alpha/include/limits.h
@@ -38,70 +38,10 @@
#ifndef _MACHINE_LIMITS_H_
#define _MACHINE_LIMITS_H_
-#define CHAR_BIT 8 /* number of bits in a char */
-
-/*
- * According to ANSI (section 2.2.4.2), the values below must be usable by
- * #if preprocessing directives. Additionally, the expression must have the
- * same type as would an expression that is an object of the corresponding
- * type converted according to the integral promotions. The subtraction for
- * INT_MIN, etc., is so the value is not unsigned; e.g., 0x80000000 is an
- * unsigned int for 32-bit two's complement ANSI compilers (section 3.1.3.2).
- * These numbers are for the default configuration of gcc. They work for
- * some other compilers as well, but this should not be depended on.
- */
-#define SCHAR_MAX 0x7f /* max value for a signed char */
-#define SCHAR_MIN (-0x7f-1) /* min value for a signed char */
-
-#define UCHAR_MAX 0xffU /* max value for an unsigned char */
-#define CHAR_MAX 0x7f /* max value for a char */
-#define CHAR_MIN (-0x7f-1) /* min value for a char */
-
-#define USHRT_MAX 0xffffU /* max value for an unsigned short */
-#define SHRT_MAX 0x7fff /* max value for a short */
-#define SHRT_MIN (-0x7fff-1) /* min value for a short */
-
-#define UINT_MAX 0xffffffffU /* max value for an unsigned int */
-#define INT_MAX 0x7fffffff /* max value for an int */
-#define INT_MIN (-0x7fffffff-1) /* min value for an int */
-
-#define ULONG_MAX 0xffffffffffffffffUL /* max for an unsigned long */
-#define LONG_MAX 0x7fffffffffffffffL /* max for a long */
-#define LONG_MIN (-0x7fffffffffffffffL-1) /* min for a long */
-
-/* Long longs and longs are the same size on the alpha. */
- /* max for an unsigned long long */
-#define ULLONG_MAX 0xffffffffffffffffULL
-#define LLONG_MAX 0x7fffffffffffffffLL /* max for a long long */
-#define LLONG_MIN (-0x7fffffffffffffffLL-1) /* min for a long long */
-
-#if !defined(_ANSI_SOURCE)
-#define SSIZE_MAX LONG_MAX /* max value for a ssize_t */
-
-#if !defined(_POSIX_SOURCE) && !defined(_XOPEN_SOURCE)
-#define SIZE_T_MAX ULONG_MAX /* max value for a size_t */
-
-#define OFF_MAX LONG_MAX /* max value for a off_t */
-#define OFF_MIN LONG_MIN /* min value for a off_t */
-
-/* Quads and longs are the same on the alpha. Ensure they stay in sync. */
-#define UQUAD_MAX (ULONG_MAX) /* max value for a uquad_t */
-#define QUAD_MAX (LONG_MAX) /* max value for a quad_t */
-#define QUAD_MIN (LONG_MIN) /* min value for a quad_t */
-#endif /* !_POSIX_SOURCE && !_XOPEN_SOURCE */
-#endif /* !_ANSI_SOURCE */
-
-#if (!defined(_ANSI_SOURCE)&&!defined(_POSIX_SOURCE)) || defined(_XOPEN_SOURCE)
-#define LONG_BIT 64
-#define WORD_BIT 32
-
-#define DBL_DIG 15
-#define DBL_MAX 1.7976931348623157E+308
-#define DBL_MIN 2.2250738585072014E-308
-
-#define FLT_DIG 6
-#define FLT_MAX 3.40282347E+38F
-#define FLT_MIN 1.17549435E-38F
+#if __GNUC__
+#warning "machine/limits.h is deprecated. Include sys/limits.h instead."
#endif
+#include <sys/limits.h>
+
#endif /* !_MACHINE_LIMITS_H_ */
diff --git a/sys/amd64/include/limits.h b/sys/amd64/include/limits.h
index e740acf1f349..8a36831908f2 100644
--- a/sys/amd64/include/limits.h
+++ b/sys/amd64/include/limits.h
@@ -39,70 +39,10 @@
#ifndef _MACHINE_LIMITS_H_
#define _MACHINE_LIMITS_H_
-#define CHAR_BIT 8 /* number of bits in a char */
-
-/*
- * According to ANSI (section 2.2.4.2), the values below must be usable by
- * #if preprocessing directives. Additionally, the expression must have the
- * same type as would an expression that is an object of the corresponding
- * type converted according to the integral promotions. The subtraction for
- * INT_MIN, etc., is so the value is not unsigned; e.g., 0x80000000 is an
- * unsigned int for 32-bit two's complement ANSI compilers (section 3.1.3.2).
- * These numbers are for the default configuration of gcc. They work for
- * some other compilers as well, but this should not be depended on.
- */
-#define SCHAR_MAX 0x7f /* max value for a signed char */
-#define SCHAR_MIN (-0x7f-1) /* min value for a signed char */
-
-#define UCHAR_MAX 0xffU /* max value for an unsigned char */
-#define CHAR_MAX 0x7f /* max value for a char */
-#define CHAR_MIN (-0x7f-1) /* min value for a char */
-
-#define USHRT_MAX 0xffffU /* max value for an unsigned short */
-#define SHRT_MAX 0x7fff /* max value for a short */
-#define SHRT_MIN (-0x7fff-1) /* min value for a short */
-
-#define UINT_MAX 0xffffffffU /* max value for an unsigned int */
-#define INT_MAX 0x7fffffff /* max value for an int */
-#define INT_MIN (-0x7fffffff-1) /* min value for an int */
-
-#define ULONG_MAX 0xffffffffffffffffUL /* max for an unsigned long */
-#define LONG_MAX 0x7fffffffffffffffL /* max for a long */
-#define LONG_MIN (-0x7fffffffffffffffL-1) /* min for a long */
-
-/* Long longs and longs are the same size on the alpha. */
- /* max for an unsigned long long */
-#define ULLONG_MAX 0xffffffffffffffffULL
-#define LLONG_MAX 0x7fffffffffffffffLL /* max for a long long */
-#define LLONG_MIN (-0x7fffffffffffffffLL-1) /* min for a long long */
-
-#if !defined(_ANSI_SOURCE)
-#define SSIZE_MAX LONG_MAX /* max value for a ssize_t */
-
-#if !defined(_POSIX_SOURCE) && !defined(_XOPEN_SOURCE)
-#define SIZE_T_MAX ULONG_MAX /* max value for a size_t */
-
-#define OFF_MAX LONG_MAX /* max value for an off_t */
-#define OFF_MIN LONG_MIN /* min value for an off_t */
-
-/* Quads and longs are the same on the alpha. Ensure they stay in sync. */
-#define UQUAD_MAX (ULONG_MAX) /* max value for a uquad_t */
-#define QUAD_MAX (LONG_MAX) /* max value for a quad_t */
-#define QUAD_MIN (LONG_MIN) /* min value for a quad_t */
-#endif /* !_POSIX_SOURCE && !_XOPEN_SOURCE */
-#endif /* !_ANSI_SOURCE */
-
-#if (!defined(_ANSI_SOURCE)&&!defined(_POSIX_SOURCE)) || defined(_XOPEN_SOURCE)
-#define LONG_BIT 64
-#define WORD_BIT 32
-
-#define DBL_DIG 15
-#define DBL_MAX 1.7976931348623157E+308
-#define DBL_MIN 2.2250738585072014E-308
-
-#define FLT_DIG 6
-#define FLT_MAX 3.40282347E+38F
-#define FLT_MIN 1.17549435E-38F
+#if __GNUC__
+#warning "machine/limits.h is deprecated. Include sys/limits.h instead."
#endif
+#include <sys/limits.h>
+
#endif /* !_MACHINE_LIMITS_H_ */
diff --git a/sys/amd64/isa/clock.c b/sys/amd64/isa/clock.c
index df1b2e9d9b94..9e6c489637e3 100644
--- a/sys/amd64/isa/clock.c
+++ b/sys/amd64/isa/clock.c
@@ -61,6 +61,7 @@
#include <sys/time.h>
#include <sys/timetc.h>
#include <sys/kernel.h>
+#include <sys/limits.h>
#include <sys/sysctl.h>
#include <sys/cons.h>
#include <sys/power.h>
@@ -68,7 +69,6 @@
#include <machine/clock.h>
#include <machine/cputypes.h>
#include <machine/frame.h>
-#include <machine/limits.h>
#include <machine/md_var.h>
#include <machine/psl.h>
#ifdef APIC_IO
diff --git a/sys/arm/include/limits.h b/sys/arm/include/limits.h
index b5e3bd1e68c7..58dac20c167c 100644
--- a/sys/arm/include/limits.h
+++ b/sys/arm/include/limits.h
@@ -34,72 +34,13 @@
* $FreeBSD$
*/
-#ifndef _MACHINE_LIMITS_H_
+#ifndef _MACHINE_LIMITS_H_
#define _MACHINE_LIMITS_H_
-#define CHAR_BIT 8 /* number of bits in a char */
-
-/*
- * According to ANSI (section 2.2.4.2), the values below must be usable by
- * #if preprocessing directives. Additionally, the expression must have the
- * same type as would an expression that is an object of the corresponding
- * type converted according to the integral promotions. The subtraction for
- * INT_MIN, etc., is so the value is not unsigned; e.g., 0x80000000 is an
- * unsigned int for 32-bit two's complement ANSI compilers (section 3.1.3.2).
- * These numbers are for the default configuration of gcc. They work for
- * some other compilers as well, but this should not be depended on.
- */
-#define SCHAR_MAX 0x7f /* max value for a signed char */
-#define SCHAR_MIN (-0x7f - 1) /* min value for a signed char */
-
-#define UCHAR_MAX 0xff /* max value for an unsigned char */
-
-#ifdef __CHAR_UNSIGNED__
-#define CHAR_MAX UCHAR_MAX /* max value for a char */
-#define CHAR_MIN 0 /* min value for a char */
-#else
-#define CHAR_MAX SCHAR_MAX /* max value for a char */
-#define CHAR_MIN SCHAR_MIN /* min value for a char */
+#if __GNUC__
+#warning "machine/limits.h is deprecated. Include sys/limits.h instead."
#endif
-#define USHRT_MAX 0xffff /* max value for an unsigned short */
-#define SHRT_MAX 0x7fff /* max value for a short */
-#define SHRT_MIN (-0x7fff - 1) /* min value for a short */
-
-#define UINT_MAX 0xffffffffU /* max value for an unsigned int */
-#define INT_MAX 0x7fffffff /* max value for an int */
-#define INT_MIN (-0x7fffffff - 1) /* min value for an int */
-
-/* Bad hack for gcc configured to give 64-bit longs. */
-#ifdef _LARGE_LONG
-#define ULONG_MAX 0xffffffffffffffffUL
-#define LONG_MAX 0x7fffffffffffffffL
-#define LONG_MIN (-0x7fffffffffffffffL - 1)
-#else
-#define ULONG_MAX 0xffffffffUL /* max value for an unsigned long */
-#define LONG_MAX 0x7fffffffL /* max value for a long */
-#define LONG_MIN (-0x7fffffffL - 1) /* min value for a long */
-#endif
-
- /* max value for an unsigned long long */
-#define ULLONG_MAX 0xffffffffffffffffULL
-#define LLONG_MAX 0x7fffffffffffffffLL /* max value for a long long */
-#define LLONG_MIN (-0x7fffffffffffffffLL - 1) /* min for a long long */
-
-#if !defined(_ANSI_SOURCE)
-#define SSIZE_MAX INT_MAX /* max value for a ssize_t */
-
-#if !defined(_POSIX_SOURCE)
-#define SIZE_T_MAX UINT_MAX /* max value for a size_t */
-
-#define OFF_MAX LLONG_MAX /* max value for a off_t */
-#define OFF_MIN LLONG_MIN /* min value for a off_t */
-
-/* Quads and long longs are the same size. Ensure they stay in sync. */
-#define UQUAD_MAX ULLONG_MAX /* max value for a uquad_t */
-#define QUAD_MAX LLONG_MAX /* max value for a quad_t */
-#define QUAD_MIN LLONG_MIN /* min value for a quad_t */
-#endif /* !_POSIX_SOURCE */
-#endif /* !_ANSI_SOURCE */
+#include <sys/limits.h>
#endif /* !_MACHINE_LIMITS_H_ */
diff --git a/sys/cam/cam_ccb.h b/sys/cam/cam_ccb.h
index 431fbb3b3cf4..706bbf93e230 100644
--- a/sys/cam/cam_ccb.h
+++ b/sys/cam/cam_ccb.h
@@ -35,7 +35,7 @@
#include <sys/cdefs.h>
#include <sys/time.h>
#ifdef CAM_NEW_TRAN_CODE
-#include <machine/limits.h>
+#include <sys/limits.h>
#endif /* CAM_NEW_TRAN_CODE */
#ifndef _KERNEL
#include <sys/callout.h>
diff --git a/sys/cam/scsi/scsi_sa.c b/sys/cam/scsi/scsi_sa.c
index e81b110c5b73..a7e40b6f2264 100644
--- a/sys/cam/scsi/scsi_sa.c
+++ b/sys/cam/scsi/scsi_sa.c
@@ -38,13 +38,13 @@
#include <sys/types.h>
#include <sys/time.h>
#include <sys/bio.h>
+#include <sys/limits.h>
#include <sys/malloc.h>
#include <sys/mtio.h>
#ifdef _KERNEL
#include <sys/conf.h>
#endif
#include <sys/devicestat.h>
-#include <machine/limits.h>
#ifndef _KERNEL
#include <stdio.h>
diff --git a/sys/compat/linux/linux_ipc.c b/sys/compat/linux/linux_ipc.c
index 64a496c4294a..92fa13d40c24 100644
--- a/sys/compat/linux/linux_ipc.c
+++ b/sys/compat/linux/linux_ipc.c
@@ -32,12 +32,11 @@
#include <sys/systm.h>
#include <sys/sysproto.h>
#include <sys/proc.h>
+#include <sys/limits.h>
#include <sys/msg.h>
#include <sys/sem.h>
#include <sys/shm.h>
-#include <machine/limits.h>
-
#include <machine/../linux/linux.h>
#include <machine/../linux/linux_proto.h>
#include <machine/../linux/linux_ipc64.h>
diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c
index 28ab2b32135e..ab0abec51ab8 100644
--- a/sys/compat/linux/linux_misc.c
+++ b/sys/compat/linux/linux_misc.c
@@ -36,6 +36,7 @@
#include <sys/imgact_aout.h>
#include <sys/jail.h>
#include <sys/kernel.h>
+#include <sys/limits.h>
#include <sys/lock.h>
#include <sys/mac.h>
#include <sys/malloc.h>
@@ -65,8 +66,6 @@
#include <vm/vm_object.h>
#include <vm/swap_pager.h>
-#include <machine/limits.h>
-
#include <posix4/sched.h>
#include <machine/../linux/linux.h>
diff --git a/sys/compat/linux/linux_socket.c b/sys/compat/linux/linux_socket.c
index e9dcb4b336cd..a521048b4df2 100644
--- a/sys/compat/linux/linux_socket.c
+++ b/sys/compat/linux/linux_socket.c
@@ -42,6 +42,7 @@
#include <sys/sysproto.h>
#include <sys/fcntl.h>
#include <sys/file.h>
+#include <sys/limits.h>
#include <sys/malloc.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
@@ -62,8 +63,6 @@
#include <compat/linux/linux_socket.h>
#include <compat/linux/linux_util.h>
-#include <machine/limits.h>
-
static int do_sa_get(struct sockaddr **, const struct osockaddr *, int *,
struct malloc_type *);
static int linux_to_bsd_domain(int);
diff --git a/sys/dev/atkbdc/atkbd.c b/sys/dev/atkbdc/atkbd.c
index e4414c59fd7f..46cd64276177 100644
--- a/sys/dev/atkbdc/atkbd.c
+++ b/sys/dev/atkbdc/atkbd.c
@@ -34,6 +34,7 @@
#include <sys/kernel.h>
#include <sys/bus.h>
#include <sys/proc.h>
+#include <sys/limits.h>
#include <sys/malloc.h>
#include <machine/bus.h>
@@ -167,8 +168,6 @@ atkbd_timeout(void *arg)
/* LOW-LEVEL */
-#include <machine/limits.h>
-
#define ATKBD_DEFAULT 0
typedef struct atkbd_state {
diff --git a/sys/dev/atkbdc/psm.c b/sys/dev/atkbdc/psm.c
index 968491d346e4..afb66ba7af02 100644
--- a/sys/dev/atkbdc/psm.c
+++ b/sys/dev/atkbdc/psm.c
@@ -77,7 +77,7 @@
#include <sys/time.h>
#include <sys/uio.h>
-#include <machine/limits.h>
+#include <sys/limits.h>
#include <sys/mouse.h>
#include <machine/resource.h>
diff --git a/sys/dev/eisa/eisaconf.c b/sys/dev/eisa/eisaconf.c
index 2b306eb04ca8..0f8f8f2ce3fd 100644
--- a/sys/dev/eisa/eisaconf.c
+++ b/sys/dev/eisa/eisaconf.c
@@ -36,12 +36,12 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/queue.h>
+#include <sys/limits.h>
#include <sys/malloc.h>
#include <sys/kernel.h>
#include <sys/module.h>
#include <sys/bus.h>
-#include <machine/limits.h>
#include <machine/bus.h>
#include <machine/resource.h>
#include <sys/rman.h>
diff --git a/sys/dev/kbd/atkbd.c b/sys/dev/kbd/atkbd.c
index e4414c59fd7f..46cd64276177 100644
--- a/sys/dev/kbd/atkbd.c
+++ b/sys/dev/kbd/atkbd.c
@@ -34,6 +34,7 @@
#include <sys/kernel.h>
#include <sys/bus.h>
#include <sys/proc.h>
+#include <sys/limits.h>
#include <sys/malloc.h>
#include <machine/bus.h>
@@ -167,8 +168,6 @@ atkbd_timeout(void *arg)
/* LOW-LEVEL */
-#include <machine/limits.h>
-
#define ATKBD_DEFAULT 0
typedef struct atkbd_state {
diff --git a/sys/dev/mca/mca_bus.c b/sys/dev/mca/mca_bus.c
index 2550dc14e139..13bdc0841e5a 100644
--- a/sys/dev/mca/mca_bus.c
+++ b/sys/dev/mca/mca_bus.c
@@ -38,10 +38,10 @@
#include <sys/queue.h>
#include <sys/malloc.h>
#include <sys/kernel.h>
+#include <sys/limits.h>
#include <sys/module.h>
#include <sys/bus.h>
-#include <machine/limits.h>
#include <machine/bus.h>
#include <machine/resource.h>
#include <sys/rman.h>
diff --git a/sys/dev/raidframe/rf_types.h b/sys/dev/raidframe/rf_types.h
index 3f388fc01168..25630eff3bf5 100644
--- a/sys/dev/raidframe/rf_types.h
+++ b/sys/dev/raidframe/rf_types.h
@@ -64,8 +64,8 @@
*/
#include <sys/types.h>
+#include <sys/limits.h>
#include <machine/endian.h>
-#include <machine/limits.h>
#if BYTE_ORDER == BIG_ENDIAN
#define RF_IS_BIG_ENDIAN 1
diff --git a/sys/dev/ray/if_ray.c b/sys/dev/ray/if_ray.c
index daf897058906..3ca2b5fed059 100644
--- a/sys/dev/ray/if_ray.c
+++ b/sys/dev/ray/if_ray.c
@@ -243,6 +243,7 @@
#include <sys/param.h>
#include <sys/systm.h>
+#include <sys/limits.h>
#include <sys/malloc.h>
#include <sys/kernel.h>
@@ -263,8 +264,6 @@
#include <net/if_ieee80211.h>
#include <net/if_llc.h>
-#include <machine/limits.h>
-
#include <dev/pccard/pccardvar.h>
#include "card_if.h"
diff --git a/sys/dev/sio/sio.c b/sys/dev/sio/sio.c
index 2a3d8acdb3ef..c448716e06ba 100644
--- a/sys/dev/sio/sio.c
+++ b/sys/dev/sio/sio.c
@@ -56,6 +56,7 @@
#include <sys/fcntl.h>
#include <sys/interrupt.h>
#include <sys/kernel.h>
+#include <sys/limits.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/module.h>
@@ -73,7 +74,6 @@
#include <isa/isavar.h>
-#include <machine/limits.h>
#include <machine/resource.h>
#include <dev/sio/sioreg.h>
diff --git a/sys/dev/sound/midi/midi.h b/sys/dev/sound/midi/midi.h
index 086765423a8f..9ba9c952366f 100644
--- a/sys/dev/sound/midi/midi.h
+++ b/sys/dev/sound/midi/midi.h
@@ -62,7 +62,7 @@
#include <machine/bus_pio.h>
#include <machine/bus.h>
#include <machine/clock.h> /* for DELAY */
-#include <machine/limits.h>
+#include <sys/limits.h>
#include <sys/soundcard.h>
#include <sys/rman.h>
#include <sys/mman.h>
diff --git a/sys/dev/syscons/scmouse.c b/sys/dev/syscons/scmouse.c
index 0c4ba2cdb457..2b3a77b16235 100644
--- a/sys/dev/syscons/scmouse.c
+++ b/sys/dev/syscons/scmouse.c
@@ -33,6 +33,7 @@
#include <sys/conf.h>
#include <sys/consio.h>
#include <sys/fbio.h>
+#include <sys/limits.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/mouse.h>
@@ -41,7 +42,6 @@
#include <sys/random.h>
#include <sys/signalvar.h>
#include <sys/tty.h>
-#include <machine/limits.h>
#include <dev/syscons/syscons.h>
diff --git a/sys/dev/usb/ukbd.c b/sys/dev/usb/ukbd.c
index 775a04d27ac9..a16d799e0c44 100644
--- a/sys/dev/usb/ukbd.c
+++ b/sys/dev/usb/ukbd.c
@@ -51,6 +51,7 @@
#include <sys/module.h>
#include <sys/bus.h>
#include <sys/file.h>
+#include <sys/limits.h>
#if __FreeBSD_version >= 500014
#include <sys/selinfo.h>
#else
@@ -235,7 +236,6 @@ ukbd_intr(usbd_xfer_handle xfer, usbd_private_handle addr, usbd_status status)
DRIVER_MODULE(ukbd, uhub, ukbd_driver, ukbd_devclass, ukbd_driver_load, 0);
-#include <machine/limits.h>
#define UKBD_DEFAULT 0
diff --git a/sys/fs/pseudofs/pseudofs_fileno.c b/sys/fs/pseudofs/pseudofs_fileno.c
index 4341e236fa9a..24848b338287 100644
--- a/sys/fs/pseudofs/pseudofs_fileno.c
+++ b/sys/fs/pseudofs/pseudofs_fileno.c
@@ -31,13 +31,12 @@
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/systm.h>
+#include <sys/limits.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/mutex.h>
#include <sys/sysctl.h>
-#include <machine/limits.h>
-
#include <fs/pseudofs/pseudofs.h>
#include <fs/pseudofs/pseudofs_internal.h>
diff --git a/sys/fs/smbfs/smbfs_vnops.c b/sys/fs/smbfs/smbfs_vnops.c
index 19b099aa8922..20bd9c633d72 100644
--- a/sys/fs/smbfs/smbfs_vnops.c
+++ b/sys/fs/smbfs/smbfs_vnops.c
@@ -42,10 +42,9 @@
#include <sys/mount.h>
#include <sys/unistd.h>
#include <sys/vnode.h>
+#include <sys/limits.h>
#include <sys/lockf.h>
-#include <machine/limits.h>
-
#include <vm/vm.h>
#include <vm/vm_extern.h>
diff --git a/sys/geom/geom_dev.c b/sys/geom/geom_dev.c
index cb4e377d8107..b090d753b56e 100644
--- a/sys/geom/geom_dev.c
+++ b/sys/geom/geom_dev.c
@@ -47,9 +47,9 @@
#include <sys/time.h>
#include <sys/disk.h>
#include <sys/fcntl.h>
+#include <sys/limits.h>
#include <geom/geom.h>
#include <geom/geom_int.h>
-#include <machine/limits.h>
static d_open_t g_dev_open;
static d_close_t g_dev_close;
diff --git a/sys/i386/include/limits.h b/sys/i386/include/limits.h
index 13ea13973348..58dac20c167c 100644
--- a/sys/i386/include/limits.h
+++ b/sys/i386/include/limits.h
@@ -34,72 +34,13 @@
* $FreeBSD$
*/
-#ifndef _MACHINE_LIMITS_H_
+#ifndef _MACHINE_LIMITS_H_
#define _MACHINE_LIMITS_H_
-#define CHAR_BIT 8 /* number of bits in a char */
-
-/*
- * According to ANSI (section 2.2.4.2), the values below must be usable by
- * #if preprocessing directives. Additionally, the expression must have the
- * same type as would an expression that is an object of the corresponding
- * type converted according to the integral promotions. The subtraction for
- * INT_MIN, etc., is so the value is not unsigned; e.g., 0x80000000 is an
- * unsigned int for 32-bit two's complement ANSI compilers (section 3.1.3.2).
- * These numbers are for the default configuration of gcc. They work for
- * some other compilers as well, but this should not be depended on.
- */
-#define SCHAR_MAX 0x7f /* max value for a signed char */
-#define SCHAR_MIN (-0x7f - 1) /* min value for a signed char */
-
-#define UCHAR_MAX 0xff /* max value for an unsigned char */
-
-#ifdef __CHAR_UNSIGNED__
-#define CHAR_MAX UCHAR_MAX /* max value for a char */
-#define CHAR_MIN 0 /* min value for a char */
-#else
-#define CHAR_MAX SCHAR_MAX /* max value for a char */
-#define CHAR_MIN SCHAR_MIN /* min value for a char */
+#if __GNUC__
+#warning "machine/limits.h is deprecated. Include sys/limits.h instead."
#endif
-#define USHRT_MAX 0xffff /* max value for an unsigned short */
-#define SHRT_MAX 0x7fff /* max value for a short */
-#define SHRT_MIN (-0x7fff - 1) /* min value for a short */
-
-#define UINT_MAX 0xffffffffU /* max value for an unsigned int */
-#define INT_MAX 0x7fffffff /* max value for an int */
-#define INT_MIN (-0x7fffffff - 1) /* min value for an int */
-
-/* Bad hack for gcc configured to give 64-bit longs. */
-#ifdef _LARGE_LONG
-#define ULONG_MAX 0xffffffffffffffffUL
-#define LONG_MAX 0x7fffffffffffffffL
-#define LONG_MIN (-0x7fffffffffffffffL - 1)
-#else
-#define ULONG_MAX 0xffffffffUL /* max value for an unsigned long */
-#define LONG_MAX 0x7fffffffL /* max value for a long */
-#define LONG_MIN (-0x7fffffffL - 1) /* min value for a long */
-#endif
-
- /* max value for an unsigned long long */
-#define ULLONG_MAX 0xffffffffffffffffULL
-#define LLONG_MAX 0x7fffffffffffffffLL /* max value for a long long */
-#define LLONG_MIN (-0x7fffffffffffffffLL - 1) /* min for a long long */
-
-#if !defined(_ANSI_SOURCE)
-#define SSIZE_MAX INT_MAX /* max value for a ssize_t */
-
-#if !defined(_POSIX_SOURCE)
-#define SIZE_T_MAX UINT_MAX /* max value for a size_t */
-
-#define OFF_MAX LLONG_MAX /* max value for an off_t */
-#define OFF_MIN LLONG_MIN /* min value for an off_t */
-
-/* Quads and long longs are the same size. Ensure they stay in sync. */
-#define UQUAD_MAX ULLONG_MAX /* max value for a uquad_t */
-#define QUAD_MAX LLONG_MAX /* max value for a quad_t */
-#define QUAD_MIN LLONG_MIN /* min value for a quad_t */
-#endif /* !_POSIX_SOURCE */
-#endif /* !_ANSI_SOURCE */
+#include <sys/limits.h>
#endif /* !_MACHINE_LIMITS_H_ */
diff --git a/sys/i386/isa/clock.c b/sys/i386/isa/clock.c
index df1b2e9d9b94..9e6c489637e3 100644
--- a/sys/i386/isa/clock.c
+++ b/sys/i386/isa/clock.c
@@ -61,6 +61,7 @@
#include <sys/time.h>
#include <sys/timetc.h>
#include <sys/kernel.h>
+#include <sys/limits.h>
#include <sys/sysctl.h>
#include <sys/cons.h>
#include <sys/power.h>
@@ -68,7 +69,6 @@
#include <machine/clock.h>
#include <machine/cputypes.h>
#include <machine/frame.h>
-#include <machine/limits.h>
#include <machine/md_var.h>
#include <machine/psl.h>
#ifdef APIC_IO
diff --git a/sys/ia64/include/limits.h b/sys/ia64/include/limits.h
index b694386cd1af..7dc0de73937d 100644
--- a/sys/ia64/include/limits.h
+++ b/sys/ia64/include/limits.h
@@ -36,68 +36,13 @@
* @(#)limits.h 8.3 (Berkeley) 1/4/94
*/
-#define CHAR_BIT 8 /* number of bits in a char */
+#ifndef _MACHINE_LIMITS_H_
+#define _MACHINE_LIMITS_H_
-/*
- * According to ANSI (section 2.2.4.2), the values below must be usable by
- * #if preprocessing directives. Additionally, the expression must have the
- * same type as would an expression that is an object of the corresponding
- * type converted according to the integral promotions. The subtraction for
- * INT_MIN, etc., is so the value is not unsigned; e.g., 0x80000000 is an
- * unsigned int for 32-bit two's complement ANSI compilers (section 3.1.3.2).
- * These numbers are for the default configuration of gcc. They work for
- * some other compilers as well, but this should not be depended on.
- */
-#define SCHAR_MAX 0x7f /* max value for a signed char */
-#define SCHAR_MIN (-0x7f-1) /* min value for a signed char */
-
-#define UCHAR_MAX 0xffU /* max value for an unsigned char */
-#define CHAR_MAX 0x7f /* max value for a char */
-#define CHAR_MIN (-0x7f-1) /* min value for a char */
-
-#define USHRT_MAX 0xffffU /* max value for an unsigned short */
-#define SHRT_MAX 0x7fff /* max value for a short */
-#define SHRT_MIN (-0x7fff-1) /* min value for a short */
-
-#define UINT_MAX 0xffffffffU /* max value for an unsigned int */
-#define INT_MAX 0x7fffffff /* max value for an int */
-#define INT_MIN (-0x7fffffff-1) /* min value for an int */
-
-#define ULONG_MAX 0xffffffffffffffffUL /* max for an unsigned long */
-#define LONG_MAX 0x7fffffffffffffffL /* max for a long */
-#define LONG_MIN (-0x7fffffffffffffffL-1) /* min for a long */
-
-/* Long longs and longs are the same size on the IA-64. */
- /* max for an unsigned long long */
-#define ULLONG_MAX 0xffffffffffffffffULL
-#define LLONG_MAX 0x7fffffffffffffffLL /* max for a long long */
-#define LLONG_MIN (-0x7fffffffffffffffLL-1) /* min for a long long */
-
-#if !defined(_ANSI_SOURCE)
-#define SSIZE_MAX LONG_MAX /* max value for a ssize_t */
-
-#if !defined(_POSIX_SOURCE) && !defined(_XOPEN_SOURCE)
-#define SIZE_T_MAX ULONG_MAX /* max value for a size_t */
-
-#define OFF_MAX LONG_MAX /* max value for an off_t */
-#define OFF_MIN LONG_MIN /* min value for an off_t */
-
-/* Quads and longs are the same. Ensure they stay in sync. */
-#define UQUAD_MAX (ULONG_MAX) /* max value for a uquad_t */
-#define QUAD_MAX (LONG_MAX) /* max value for a quad_t */
-#define QUAD_MIN (LONG_MIN) /* min value for a quad_t */
-#endif /* !_POSIX_SOURCE && !_XOPEN_SOURCE */
-#endif /* !_ANSI_SOURCE */
-
-#if (!defined(_ANSI_SOURCE)&&!defined(_POSIX_SOURCE)) || defined(_XOPEN_SOURCE)
-#define LONG_BIT 64
-#define WORD_BIT 32
+#if __GNUC__
+#warning "machine/limits.h is deprecated. Include sys/limits.h instead."
+#endif
-#define DBL_DIG 15
-#define DBL_MAX 1.7976931348623157E+308
-#define DBL_MIN 2.2250738585072014E-308
+#include <sys/limits.h>
-#define FLT_DIG 6
-#define FLT_MAX 3.40282347E+38F
-#define FLT_MIN 1.17549435E-38F
-#endif
+#endif /* !_MACHINE_LIMITS_H_ */
diff --git a/sys/isa/atrtc.c b/sys/isa/atrtc.c
index df1b2e9d9b94..9e6c489637e3 100644
--- a/sys/isa/atrtc.c
+++ b/sys/isa/atrtc.c
@@ -61,6 +61,7 @@
#include <sys/time.h>
#include <sys/timetc.h>
#include <sys/kernel.h>
+#include <sys/limits.h>
#include <sys/sysctl.h>
#include <sys/cons.h>
#include <sys/power.h>
@@ -68,7 +69,6 @@
#include <machine/clock.h>
#include <machine/cputypes.h>
#include <machine/frame.h>
-#include <machine/limits.h>
#include <machine/md_var.h>
#include <machine/psl.h>
#ifdef APIC_IO
diff --git a/sys/isa/psm.c b/sys/isa/psm.c
index 968491d346e4..afb66ba7af02 100644
--- a/sys/isa/psm.c
+++ b/sys/isa/psm.c
@@ -77,7 +77,7 @@
#include <sys/time.h>
#include <sys/uio.h>
-#include <machine/limits.h>
+#include <sys/limits.h>
#include <sys/mouse.h>
#include <machine/resource.h>
diff --git a/sys/kern/kern_clock.c b/sys/kern/kern_clock.c
index 3d04cf0eeab5..0482d53f34f9 100644
--- a/sys/kern/kern_clock.c
+++ b/sys/kern/kern_clock.c
@@ -60,10 +60,10 @@
#include <sys/sysctl.h>
#include <sys/bus.h>
#include <sys/interrupt.h>
+#include <sys/limits.h>
#include <sys/timetc.h>
#include <machine/cpu.h>
-#include <machine/limits.h>
#ifdef GPROF
#include <sys/gmon.h>
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c
index 0d0297457047..6975d0ec3179 100644
--- a/sys/kern/kern_descrip.c
+++ b/sys/kern/kern_descrip.c
@@ -49,6 +49,7 @@
#include <sys/filedesc.h>
#include <sys/lock.h>
#include <sys/kernel.h>
+#include <sys/limits.h>
#include <sys/malloc.h>
#include <sys/mutex.h>
#include <sys/sysctl.h>
@@ -67,8 +68,6 @@
#include <sys/socketvar.h>
#include <sys/signalvar.h>
-#include <machine/limits.h>
-
#include <vm/vm.h>
#include <vm/vm_extern.h>
#include <vm/uma.h>
diff --git a/sys/kern/kern_lockf.c b/sys/kern/kern_lockf.c
index 7a7379b393d7..ca2ba302fe07 100644
--- a/sys/kern/kern_lockf.c
+++ b/sys/kern/kern_lockf.c
@@ -42,6 +42,7 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
+#include <sys/limits.h>
#include <sys/lock.h>
#include <sys/mount.h>
#include <sys/mutex.h>
@@ -52,8 +53,6 @@
#include <sys/fcntl.h>
#include <sys/lockf.h>
-#include <machine/limits.h>
-
/*
* This variable controls the maximum number of processes that will
* be checked in doing deadlock detection.
diff --git a/sys/kern/subr_scanf.c b/sys/kern/subr_scanf.c
index f204f1906c24..675f14565260 100644
--- a/sys/kern/subr_scanf.c
+++ b/sys/kern/subr_scanf.c
@@ -42,7 +42,7 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/ctype.h>
-#include <machine/limits.h>
+#include <sys/limits.h>
/*
* Note that stdarg.h and the ANSI style va_start macro is used for both
diff --git a/sys/kern/sys_generic.c b/sys/kern/sys_generic.c
index c26cf47dcee1..98506f39a3d3 100644
--- a/sys/kern/sys_generic.c
+++ b/sys/kern/sys_generic.c
@@ -53,6 +53,7 @@
#include <sys/socketvar.h>
#include <sys/uio.h>
#include <sys/kernel.h>
+#include <sys/limits.h>
#include <sys/malloc.h>
#include <sys/poll.h>
#include <sys/resourcevar.h>
@@ -69,8 +70,6 @@
#include <vm/vm.h>
#include <vm/vm_page.h>
-#include <machine/limits.h>
-
static MALLOC_DEFINE(M_IOCTLOPS, "ioctlops", "ioctl data buffer");
static MALLOC_DEFINE(M_SELECT, "select", "select() buffer");
MALLOC_DEFINE(M_IOV, "iov", "large iov's");
diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c
index 7c13722f8a7a..f50f59f502ac 100644
--- a/sys/kern/uipc_socket.c
+++ b/sys/kern/uipc_socket.c
@@ -41,6 +41,7 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/fcntl.h>
+#include <sys/limits.h>
#include <sys/lock.h>
#include <sys/mac.h>
#include <sys/malloc.h>
@@ -63,7 +64,6 @@
#include <vm/uma.h>
-#include <machine/limits.h>
#ifdef INET
static int do_setopt_accept_filter(struct socket *so, struct sockopt *sopt);
diff --git a/sys/kern/vfs_aio.c b/sys/kern/vfs_aio.c
index ddfda949c2fa..f9a3fbe26235 100644
--- a/sys/kern/vfs_aio.c
+++ b/sys/kern/vfs_aio.c
@@ -32,6 +32,7 @@
#include <sys/kthread.h>
#include <sys/fcntl.h>
#include <sys/file.h>
+#include <sys/limits.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/unistd.h>
@@ -56,8 +57,6 @@
#include <vm/uma.h>
#include <sys/aio.h>
-#include <machine/limits.h>
-
#include "opt_vfs_aio.h"
/*
diff --git a/sys/kern/vfs_default.c b/sys/kern/vfs_default.c
index 556c37e621ab..7e3f295cc37a 100644
--- a/sys/kern/vfs_default.c
+++ b/sys/kern/vfs_default.c
@@ -45,6 +45,7 @@
#include <sys/buf.h>
#include <sys/conf.h>
#include <sys/kernel.h>
+#include <sys/limits.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/mount.h>
@@ -53,8 +54,6 @@
#include <sys/vnode.h>
#include <sys/poll.h>
-#include <machine/limits.h>
-
#include <vm/vm.h>
#include <vm/vm_object.h>
#include <vm/vm_extern.h>
diff --git a/sys/kern/vfs_extattr.c b/sys/kern/vfs_extattr.c
index 21b2046c9bfb..5d41208b8dd7 100644
--- a/sys/kern/vfs_extattr.c
+++ b/sys/kern/vfs_extattr.c
@@ -58,6 +58,7 @@
#include <sys/kernel.h>
#include <sys/fcntl.h>
#include <sys/file.h>
+#include <sys/limits.h>
#include <sys/linker.h>
#include <sys/stat.h>
#include <sys/sx.h>
@@ -70,7 +71,6 @@
#include <sys/syscallsubr.h>
#include <sys/sysctl.h>
-#include <machine/limits.h>
#include <machine/stdarg.h>
#include <vm/vm.h>
diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c
index 21b2046c9bfb..5d41208b8dd7 100644
--- a/sys/kern/vfs_syscalls.c
+++ b/sys/kern/vfs_syscalls.c
@@ -58,6 +58,7 @@
#include <sys/kernel.h>
#include <sys/fcntl.h>
#include <sys/file.h>
+#include <sys/limits.h>
#include <sys/linker.h>
#include <sys/stat.h>
#include <sys/sx.h>
@@ -70,7 +71,6 @@
#include <sys/syscallsubr.h>
#include <sys/sysctl.h>
-#include <machine/limits.h>
#include <machine/stdarg.h>
#include <vm/vm.h>
diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c
index a01733fe8fcd..589a372fbea4 100644
--- a/sys/kern/vfs_vnops.c
+++ b/sys/kern/vfs_vnops.c
@@ -47,6 +47,7 @@
#include <sys/file.h>
#include <sys/stat.h>
#include <sys/proc.h>
+#include <sys/limits.h>
#include <sys/lock.h>
#include <sys/mac.h>
#include <sys/mount.h>
@@ -61,8 +62,6 @@
#include <sys/conf.h>
#include <sys/syslog.h>
-#include <machine/limits.h>
-
static fo_rdwr_t vn_read;
static fo_rdwr_t vn_write;
static fo_ioctl_t vn_ioctl;
diff --git a/sys/libkern/quad.h b/sys/libkern/quad.h
index a2566e2f94d1..0e48e1232db8 100644
--- a/sys/libkern/quad.h
+++ b/sys/libkern/quad.h
@@ -59,8 +59,8 @@
#include <sys/cdefs.h>
#include <sys/types.h>
+#include <sys/limits.h>
#include <sys/syslimits.h>
-#include <machine/limits.h>
/*
* Depending on the desired operation, we view a `long long' (aka quad_t) in
diff --git a/sys/libkern/strtol.c b/sys/libkern/strtol.c
index f645cb5dfd82..9fb5e367fb68 100644
--- a/sys/libkern/strtol.c
+++ b/sys/libkern/strtol.c
@@ -41,7 +41,7 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/ctype.h>
-#include <machine/limits.h>
+#include <sys/limits.h>
/*
* Convert a string to a long integer.
diff --git a/sys/libkern/strtoq.c b/sys/libkern/strtoq.c
index a1bb4ffc7511..fa070815509c 100644
--- a/sys/libkern/strtoq.c
+++ b/sys/libkern/strtoq.c
@@ -39,7 +39,7 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/ctype.h>
-#include <machine/limits.h>
+#include <sys/limits.h>
/*
* Convert a string to a quad integer.
diff --git a/sys/libkern/strtoul.c b/sys/libkern/strtoul.c
index b5973ef8a686..c9ca8e4040fe 100644
--- a/sys/libkern/strtoul.c
+++ b/sys/libkern/strtoul.c
@@ -41,7 +41,7 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/ctype.h>
-#include <machine/limits.h>
+#include <sys/limits.h>
/*
* Convert a string to an unsigned long integer.
diff --git a/sys/libkern/strtouq.c b/sys/libkern/strtouq.c
index 7b6ca1a9087c..f80f2b48a460 100644
--- a/sys/libkern/strtouq.c
+++ b/sys/libkern/strtouq.c
@@ -39,7 +39,7 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/ctype.h>
-#include <machine/limits.h>
+#include <sys/limits.h>
/*
* Convert a string to an unsigned quad integer.
diff --git a/sys/netgraph/ng_base.c b/sys/netgraph/ng_base.c
index 786eecd56e8e..8135c6e821f2 100644
--- a/sys/netgraph/ng_base.c
+++ b/sys/netgraph/ng_base.c
@@ -48,6 +48,7 @@
#include <sys/systm.h>
#include <sys/errno.h>
#include <sys/kernel.h>
+#include <sys/limits.h>
#include <sys/malloc.h>
#include <sys/syslog.h>
#include <sys/sysctl.h>
@@ -56,7 +57,6 @@
#include <sys/mbuf.h>
#include <sys/ctype.h>
#include <sys/sysctl.h>
-#include <machine/limits.h>
#include <net/netisr.h>
diff --git a/sys/netgraph/ng_ppp.c b/sys/netgraph/ng_ppp.c
index 6dfa4a4ac74b..a11335fa37cc 100644
--- a/sys/netgraph/ng_ppp.c
+++ b/sys/netgraph/ng_ppp.c
@@ -47,14 +47,13 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
+#include <sys/limits.h>
#include <sys/time.h>
#include <sys/mbuf.h>
#include <sys/malloc.h>
#include <sys/errno.h>
#include <sys/ctype.h>
-#include <machine/limits.h>
-
#include <netgraph/ng_message.h>
#include <netgraph/netgraph.h>
#include <netgraph/ng_parse.h>
diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c
index 316977c3a08f..4f46ca6d8fbc 100644
--- a/sys/netinet/in_pcb.c
+++ b/sys/netinet/in_pcb.c
@@ -39,6 +39,7 @@
#include <sys/param.h>
#include <sys/systm.h>
+#include <sys/limits.h>
#include <sys/malloc.h>
#include <sys/mbuf.h>
#include <sys/domain.h>
@@ -50,8 +51,6 @@
#include <sys/kernel.h>
#include <sys/sysctl.h>
-#include <machine/limits.h>
-
#include <vm/uma.h>
#include <net/if.h>
diff --git a/sys/nfsclient/nfs_lock.c b/sys/nfsclient/nfs_lock.c
index 550a133ddb6a..ac0f3817b34b 100644
--- a/sys/nfsclient/nfs_lock.c
+++ b/sys/nfsclient/nfs_lock.c
@@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$");
#include <sys/systm.h>
#include <sys/fcntl.h>
#include <sys/kernel.h> /* for hz */
+#include <sys/limits.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/lockf.h> /* for hz */ /* Must come after sys/malloc.h */
@@ -48,8 +49,6 @@ __FBSDID("$FreeBSD$");
#include <sys/unistd.h>
#include <sys/vnode.h>
-#include <machine/limits.h>
-
#include <net/if.h>
#include <nfs/rpcv2.h>
diff --git a/sys/nfsclient/nfs_vfsops.c b/sys/nfsclient/nfs_vfsops.c
index acef9ea6fd43..8764b2b0677e 100644
--- a/sys/nfsclient/nfs_vfsops.c
+++ b/sys/nfsclient/nfs_vfsops.c
@@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
+#include <sys/limits.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/mbuf.h>
@@ -74,8 +75,6 @@ __FBSDID("$FreeBSD$");
#include <nfsclient/nfsm_subs.h>
#include <nfsclient/nfsdiskless.h>
-#include <machine/limits.h>
-
MALLOC_DEFINE(M_NFSREQ, "NFS req", "NFS request header");
MALLOC_DEFINE(M_NFSBIGFH, "NFSV3 bigfh", "NFS version 3 file handle");
MALLOC_DEFINE(M_NFSDIROFF, "NFSV3 diroff", "NFS directory offset data");
diff --git a/sys/pc98/cbus/clock.c b/sys/pc98/cbus/clock.c
index 29cee686b138..bc03ea6a0b6b 100644
--- a/sys/pc98/cbus/clock.c
+++ b/sys/pc98/cbus/clock.c
@@ -59,6 +59,7 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
+#include <sys/limits.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/proc.h>
@@ -72,7 +73,6 @@
#include <machine/clock.h>
#include <machine/cputypes.h>
#include <machine/frame.h>
-#include <machine/limits.h>
#include <machine/md_var.h>
#include <machine/psl.h>
#ifdef APIC_IO
diff --git a/sys/pc98/cbus/pckbd.c b/sys/pc98/cbus/pckbd.c
index 60e01a423473..37fe6d258400 100644
--- a/sys/pc98/cbus/pckbd.c
+++ b/sys/pc98/cbus/pckbd.c
@@ -263,7 +263,7 @@ pckbd_timeout(void *arg)
/* LOW-LEVEL */
-#include <machine/limits.h>
+#include <sys/limits.h>
#define PC98KBD_DEFAULT 0
diff --git a/sys/pc98/cbus/pcrtc.c b/sys/pc98/cbus/pcrtc.c
index 29cee686b138..bc03ea6a0b6b 100644
--- a/sys/pc98/cbus/pcrtc.c
+++ b/sys/pc98/cbus/pcrtc.c
@@ -59,6 +59,7 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
+#include <sys/limits.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/proc.h>
@@ -72,7 +73,6 @@
#include <machine/clock.h>
#include <machine/cputypes.h>
#include <machine/frame.h>
-#include <machine/limits.h>
#include <machine/md_var.h>
#include <machine/psl.h>
#ifdef APIC_IO
diff --git a/sys/pc98/cbus/sio.c b/sys/pc98/cbus/sio.c
index a9213eec67c3..b571fefa4d46 100644
--- a/sys/pc98/cbus/sio.c
+++ b/sys/pc98/cbus/sio.c
@@ -119,6 +119,7 @@
#include <sys/fcntl.h>
#include <sys/interrupt.h>
#include <sys/kernel.h>
+#include <sys/limits.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/module.h>
@@ -135,7 +136,6 @@
#include <isa/isavar.h>
-#include <machine/limits.h>
#include <machine/resource.h>
#include <dev/sio/sioreg.h>
diff --git a/sys/pc98/pc98/clock.c b/sys/pc98/pc98/clock.c
index 29cee686b138..bc03ea6a0b6b 100644
--- a/sys/pc98/pc98/clock.c
+++ b/sys/pc98/pc98/clock.c
@@ -59,6 +59,7 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
+#include <sys/limits.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/proc.h>
@@ -72,7 +73,6 @@
#include <machine/clock.h>
#include <machine/cputypes.h>
#include <machine/frame.h>
-#include <machine/limits.h>
#include <machine/md_var.h>
#include <machine/psl.h>
#ifdef APIC_IO
diff --git a/sys/pc98/pc98/pc98kbd.c b/sys/pc98/pc98/pc98kbd.c
index 60e01a423473..37fe6d258400 100644
--- a/sys/pc98/pc98/pc98kbd.c
+++ b/sys/pc98/pc98/pc98kbd.c
@@ -263,7 +263,7 @@ pckbd_timeout(void *arg)
/* LOW-LEVEL */
-#include <machine/limits.h>
+#include <sys/limits.h>
#define PC98KBD_DEFAULT 0
diff --git a/sys/pc98/pc98/sio.c b/sys/pc98/pc98/sio.c
index a9213eec67c3..b571fefa4d46 100644
--- a/sys/pc98/pc98/sio.c
+++ b/sys/pc98/pc98/sio.c
@@ -119,6 +119,7 @@
#include <sys/fcntl.h>
#include <sys/interrupt.h>
#include <sys/kernel.h>
+#include <sys/limits.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/module.h>
@@ -135,7 +136,6 @@
#include <isa/isavar.h>
-#include <machine/limits.h>
#include <machine/resource.h>
#include <dev/sio/sioreg.h>
diff --git a/sys/powerpc/include/limits.h b/sys/powerpc/include/limits.h
index 1b06efdacdc8..58dac20c167c 100644
--- a/sys/powerpc/include/limits.h
+++ b/sys/powerpc/include/limits.h
@@ -34,75 +34,13 @@
* $FreeBSD$
*/
-#ifndef _MACHINE_LIMITS_H_
+#ifndef _MACHINE_LIMITS_H_
#define _MACHINE_LIMITS_H_
-#define CHAR_BIT 8 /* number of bits in a char */
-
-/*
- * According to ANSI (section 2.2.4.2), the values below must be usable by
- * #if preprocessing directives. Additionally, the expression must have the
- * same type as would an expression that is an object of the corresponding
- * type converted according to the integral promotions. The subtraction for
- * INT_MIN, etc., is so the value is not unsigned; e.g., 0x80000000 is an
- * unsigned int for 32-bit two's complement ANSI compilers (section 3.1.3.2).
- * These numbers are for the default configuration of gcc. They work for
- * some other compilers as well, but this should not be depended on.
- */
-#define SCHAR_MAX 0x7f /* max value for a signed char */
-#define SCHAR_MIN (-0x7f - 1) /* min value for a signed char */
-
-#define UCHAR_MAX 0xff /* max value for an unsigned char */
-
-#ifdef __CHAR_UNSIGNED__
-#define CHAR_MAX UCHAR_MAX /* max value for a char */
-#define CHAR_MIN 0 /* min value for a char */
-#else
-#define CHAR_MAX SCHAR_MAX /* max value for a char */
-#define CHAR_MIN SCHAR_MIN /* min value for a char */
+#if __GNUC__
+#warning "machine/limits.h is deprecated. Include sys/limits.h instead."
#endif
-#define USHRT_MAX 0xffff /* max value for an unsigned short */
-#define SHRT_MAX 0x7fff /* max value for a short */
-#define SHRT_MIN (-0x7fff - 1) /* min value for a short */
-
-#define UINT_MAX 0xffffffffU /* max value for an unsigned int */
-#define INT_MAX 0x7fffffff /* max value for an int */
-#define INT_MIN (-0x7fffffff - 1) /* min value for an int */
-
-/* Bad hack for gcc configured to give 64-bit longs. */
-#ifdef _LARGE_LONG
-#define ULONG_MAX 0xffffffffffffffffUL
-#define LONG_MAX 0x7fffffffffffffffL
-#define LONG_MIN (-0x7fffffffffffffffL - 1)
-#else
-#define ULONG_MAX 0xffffffffUL /* max value for an unsigned long */
-#define LONG_MAX 0x7fffffffL /* max value for a long */
-#define LONG_MIN (-0x7fffffffL - 1) /* min value for a long */
-#endif
-
- /* max value for an unsigned long long */
-#define ULLONG_MAX 0xffffffffffffffffULL
-#define LLONG_MAX 0x7fffffffffffffffLL /* max value for a long long */
-#define LLONG_MIN (-0x7fffffffffffffffLL - 1) /* min for a long long */
-
-#if !defined(_ANSI_SOURCE)
-#define SSIZE_MAX INT_MAX /* max value for a ssize_t */
-
-#if !defined(_POSIX_SOURCE)
-#define SIZE_T_MAX UINT_MAX /* max value for a size_t */
-
-#define OFF_MAX LLONG_MAX /* max value for an off_t */
-#define OFF_MIN LLONG_MIN /* min value for an off_t */
-
-/* Quads and long longs are the same size. Ensure they stay in sync. */
-#define UQUAD_MAX ULLONG_MAX /* max value for a uquad_t */
-#define QUAD_MAX LLONG_MAX /* max value for a quad_t */
-#define QUAD_MIN LLONG_MIN /* min value for a quad_t */
-
-#define LONG_BIT 32
-
-#endif /* !_POSIX_SOURCE */
-#endif /* !_ANSI_SOURCE */
+#include <sys/limits.h>
#endif /* !_MACHINE_LIMITS_H_ */
diff --git a/sys/sparc64/include/limits.h b/sys/sparc64/include/limits.h
index be8cf0db5fe0..60ebf8f74468 100644
--- a/sys/sparc64/include/limits.h
+++ b/sys/sparc64/include/limits.h
@@ -30,70 +30,10 @@
#ifndef _MACHINE_LIMITS_H_
#define _MACHINE_LIMITS_H_
-#define CHAR_BIT 8 /* number of bits in a char */
-
-/*
- * According to ANSI (section 2.2.4.2), the values below must be usable by
- * #if preprocessing directives. Additionally, the expression must have the
- * same type as would an expression that is an object of the corresponding
- * type converted according to the integral promotions. The subtraction for
- * INT_MIN, etc., is so the value is not unsigned; e.g., 0x80000000 is an
- * unsigned int for 32-bit two's complement ANSI compilers (section 3.1.3.2).
- * These numbers are for the default configuration of gcc. They work for
- * some other compilers as well, but this should not be depended on.
- */
-#define SCHAR_MAX 0x7f /* max value for a signed char */
-#define SCHAR_MIN (-0x7f-1) /* min value for a signed char */
-
-#define UCHAR_MAX 0xffU /* max value for an unsigned char */
-#define CHAR_MAX 0x7f /* max value for a char */
-#define CHAR_MIN (-0x7f-1) /* min value for a char */
-
-#define USHRT_MAX 0xffffU /* max value for an unsigned short */
-#define SHRT_MAX 0x7fff /* max value for a short */
-#define SHRT_MIN (-0x7fff-1) /* min value for a short */
-
-#define UINT_MAX 0xffffffffU /* max value for an unsigned int */
-#define INT_MAX 0x7fffffff /* max value for an int */
-#define INT_MIN (-0x7fffffff-1) /* min value for an int */
-
-#define ULONG_MAX 0xffffffffffffffffUL /* max for an unsigned long */
-#define LONG_MAX 0x7fffffffffffffffL /* max for a long */
-#define LONG_MIN (-0x7fffffffffffffffL-1) /* min for a long */
-
-/* Long longs and longs are the same size on the alpha. */
- /* max for an unsigned long long */
-#define ULLONG_MAX 0xffffffffffffffffULL
-#define LLONG_MAX 0x7fffffffffffffffLL /* max for a long long */
-#define LLONG_MIN (-0x7fffffffffffffffLL-1) /* min for a long long */
-
-#if !defined(_ANSI_SOURCE)
-#define SSIZE_MAX LONG_MAX /* max value for a ssize_t */
-
-#if !defined(_POSIX_SOURCE) && !defined(_XOPEN_SOURCE)
-#define SIZE_T_MAX ULONG_MAX /* max value for a size_t */
-
-#define OFF_MAX LONG_MAX /* max value for an off_t */
-#define OFF_MIN LONG_MIN /* min value for an off_t */
-
-/* Quads and longs are the same on the alpha. Ensure they stay in sync. */
-#define UQUAD_MAX (ULONG_MAX) /* max value for a uquad_t */
-#define QUAD_MAX (LONG_MAX) /* max value for a quad_t */
-#define QUAD_MIN (LONG_MIN) /* min value for a quad_t */
-#endif /* !_POSIX_SOURCE && !_XOPEN_SOURCE */
-#endif /* !_ANSI_SOURCE */
-
-#if (!defined(_ANSI_SOURCE)&&!defined(_POSIX_SOURCE)) || defined(_XOPEN_SOURCE)
-#define LONG_BIT 64
-#define WORD_BIT 32
-
-#define DBL_DIG 15
-#define DBL_MAX 1.7976931348623157E+308
-#define DBL_MIN 2.2250738585072014E-308
-
-#define FLT_DIG 6
-#define FLT_MAX 3.40282347E+38F
-#define FLT_MIN 1.17549435E-38F
+#if __GNUC__
+#warning "machine/limits.h is deprecated. Include sys/limits.h instead."
#endif
+#include <sys/limits.h>
+
#endif /* !_MACHINE_LIMITS_H_ */
diff --git a/sys/sys/param.h b/sys/sys/param.h
index 78464bd536fc..dffea105392e 100644
--- a/sys/sys/param.h
+++ b/sys/sys/param.h
@@ -104,7 +104,7 @@
/* Machine type dependent parameters. */
#include <machine/param.h>
#ifndef _KERNEL
-#include <machine/limits.h>
+#include <sys/limits.h>
#endif
#ifndef _NO_NAMESPACE_POLLUTION
diff --git a/sys/ufs/ffs/ffs_rawread.c b/sys/ufs/ffs/ffs_rawread.c
index 3b8912928116..7e87293f3095 100644
--- a/sys/ufs/ffs/ffs_rawread.c
+++ b/sys/ufs/ffs/ffs_rawread.c
@@ -32,6 +32,7 @@
#include <sys/file.h>
#include <sys/stat.h>
#include <sys/proc.h>
+#include <sys/limits.h>
#include <sys/mount.h>
#include <sys/namei.h>
#include <sys/vnode.h>
@@ -44,7 +45,6 @@
#include <ufs/ufs/inode.h>
#include <ufs/ffs/fs.h>
-#include <machine/limits.h>
#include <vm/vm.h>
#include <vm/vm_extern.h>
#include <vm/vm_object.h>
diff --git a/sys/ufs/ffs/ffs_vnops.c b/sys/ufs/ffs/ffs_vnops.c
index 8742a5b26d2f..eda8b0b09491 100644
--- a/sys/ufs/ffs/ffs_vnops.c
+++ b/sys/ufs/ffs/ffs_vnops.c
@@ -50,6 +50,7 @@
#include <sys/conf.h>
#include <sys/extattr.h>
#include <sys/kernel.h>
+#include <sys/limits.h>
#include <sys/malloc.h>
#include <sys/mount.h>
#include <sys/proc.h>
@@ -59,8 +60,6 @@
#include <sys/vmmeter.h>
#include <sys/vnode.h>
-#include <machine/limits.h>
-
#include <vm/vm.h>
#include <vm/vm_extern.h>
#include <vm/vm_object.h>
diff --git a/sys/vm/vm_glue.c b/sys/vm/vm_glue.c
index 765f23c64660..cd00c3345c26 100644
--- a/sys/vm/vm_glue.c
+++ b/sys/vm/vm_glue.c
@@ -66,6 +66,7 @@
#include <sys/param.h>
#include <sys/systm.h>
+#include <sys/limits.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/proc.h>
@@ -79,8 +80,6 @@
#include <sys/ktr.h>
#include <sys/unistd.h>
-#include <machine/limits.h>
-
#include <vm/vm.h>
#include <vm/vm_param.h>
#include <vm/pmap.h>