aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2011-10-06 16:46:47 -0700
committerAlon Zakai <alonzakai@gmail.com>2011-10-06 16:46:47 -0700
commitfc437084c77ad1ab578e3933c3b9f08ea20e2d59 (patch)
tree65ccf84eedefbd1ab57abeafdab74f646345609a
parentce6b7ea953dd0a974a0123e6674803a3b0b1f5a2 (diff)
compilation and header fixes
-rw-r--r--system/include/bsd/float.h85
-rw-r--r--system/include/bsd/readme.txt2
-rw-r--r--system/include/bsd/sys/mman.h (renamed from system/include/freebsd/sys/mman.h)0
-rw-r--r--system/include/bsd/sys/utsname.h (renamed from system/include/freebsd/sys/utsname.h)0
-rw-r--r--system/include/freebsd/readme.txt2
-rw-r--r--system/include/libc/endian.h3
-rw-r--r--system/include/libc/stdlib.h2
-rw-r--r--system/include/libc/string.h5
-rw-r--r--system/include/libc/sys/resource.h17
-rw-r--r--system/include/sys/select.h3
-rw-r--r--tools/shared.py5
11 files changed, 115 insertions, 9 deletions
diff --git a/system/include/bsd/float.h b/system/include/bsd/float.h
new file mode 100644
index 00000000..33e1b9d9
--- /dev/null
+++ b/system/include/bsd/float.h
@@ -0,0 +1,85 @@
+/* $OpenBSD: float.h,v 1.9 2011/08/29 13:13:21 kettenis Exp $ */
+/* $NetBSD: float.h,v 1.8 1995/06/20 20:45:37 jtc Exp $ */
+
+/*
+ * Copyright (c) 1989 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
+ * 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. 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 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.
+ *
+ * @(#)float.h 7.1 (Berkeley) 5/8/90
+ */
+
+#ifndef _MACHINE_FLOAT_H_
+#define _MACHINE_FLOAT_H_
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+int __flt_rounds(void);
+__END_DECLS
+
+#define FLT_RADIX 2 /* b */
+#define FLT_ROUNDS __flt_rounds()
+#if __ISO_C_VISIBLE >= 1999
+#define FLT_EVAL_METHOD 2 /* long double */
+#endif
+
+#define FLT_MANT_DIG 24 /* p */
+#define FLT_EPSILON 1.19209290E-07F /* b**(1-p) */
+#define FLT_DIG 6 /* floor((p-1)*log10(b))+(b == 10) */
+#define FLT_MIN_EXP (-125) /* emin */
+#define FLT_MIN 1.17549435E-38F /* b**(emin-1) */
+#define FLT_MIN_10_EXP (-37) /* ceil(log10(b**(emin-1))) */
+#define FLT_MAX_EXP 128 /* emax */
+#define FLT_MAX 3.40282347E+38F /* (1-b**(-p))*b**emax */
+#define FLT_MAX_10_EXP 38 /* floor(log10((1-b**(-p))*b**emax)) */
+
+#define DBL_MANT_DIG 53
+#define DBL_EPSILON 2.2204460492503131E-16
+#define DBL_DIG 15
+#define DBL_MIN_EXP (-1021)
+#define DBL_MIN 2.2250738585072014E-308
+#define DBL_MIN_10_EXP (-307)
+#define DBL_MAX_EXP 1024
+#define DBL_MAX 1.7976931348623157E+308
+#define DBL_MAX_10_EXP 308
+
+#define LDBL_MANT_DIG 64
+#define LDBL_EPSILON 1.08420217248550443401e-19L
+#define LDBL_DIG 18
+#define LDBL_MIN_EXP (-16381)
+#define LDBL_MIN 3.36210314311209350626e-4932L
+#define LDBL_MIN_10_EXP (-4931)
+#define LDBL_MAX_EXP 16384
+#define LDBL_MAX 1.18973149535723176502e+4932L
+#define LDBL_MAX_10_EXP 4932
+
+#if __ISO_C_VISIBLE >= 1999
+#define DECIMAL_DIG 21
+#endif
+
+#endif /* _MACHINE_FLOAT_H_ */
+
diff --git a/system/include/bsd/readme.txt b/system/include/bsd/readme.txt
new file mode 100644
index 00000000..b5a40cc0
--- /dev/null
+++ b/system/include/bsd/readme.txt
@@ -0,0 +1,2 @@
+The contents of this directory are from FreeBSD or OpenBSD (see details in each file).
+
diff --git a/system/include/freebsd/sys/mman.h b/system/include/bsd/sys/mman.h
index dea9bcae..dea9bcae 100644
--- a/system/include/freebsd/sys/mman.h
+++ b/system/include/bsd/sys/mman.h
diff --git a/system/include/freebsd/sys/utsname.h b/system/include/bsd/sys/utsname.h
index 136d46b0..136d46b0 100644
--- a/system/include/freebsd/sys/utsname.h
+++ b/system/include/bsd/sys/utsname.h
diff --git a/system/include/freebsd/readme.txt b/system/include/freebsd/readme.txt
deleted file mode 100644
index 34c022c6..00000000
--- a/system/include/freebsd/readme.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-The contents of this directory are from FreeBSD.
-
diff --git a/system/include/libc/endian.h b/system/include/libc/endian.h
new file mode 100644
index 00000000..e2ccbebb
--- /dev/null
+++ b/system/include/libc/endian.h
@@ -0,0 +1,3 @@
+
+#include "machine/endian.h"
+
diff --git a/system/include/libc/stdlib.h b/system/include/libc/stdlib.h
index cf7fe8b9..fb94b9f8 100644
--- a/system/include/libc/stdlib.h
+++ b/system/include/libc/stdlib.h
@@ -198,7 +198,7 @@ int _EXFUN(unsetenv,(const char *__string));
int _EXFUN(_unsetenv_r,(struct _reent *, const char *__string));
#endif
-#ifdef __rtems__
+#if defined(__rtems__) || defined(EMSCRIPTEN)
int _EXFUN(posix_memalign,(void **, size_t, size_t));
#endif
diff --git a/system/include/libc/string.h b/system/include/libc/string.h
index 9962768c..146d602c 100644
--- a/system/include/libc/string.h
+++ b/system/include/libc/string.h
@@ -40,13 +40,13 @@ char *_EXFUN(strrchr,(const char *, int));
size_t _EXFUN(strspn,(const char *, const char *));
char *_EXFUN(strstr,(const char *, const char *));
-#ifndef _REENT_ONLY
+#if defined(EMSCRIPTEN) || !defined(_REENT_ONLY)
char *_EXFUN(strtok,(char *, const char *));
#endif
size_t _EXFUN(strxfrm,(char *, const char *, size_t));
-#ifndef __STRICT_ANSI__
+#if defined(EMSCRIPTEN) || !defined(__STRICT_ANSI__)
char *_EXFUN(strtok_r,(char *, const char *, char **));
int _EXFUN(bcmp,(const void *, const void *, size_t));
@@ -102,3 +102,4 @@ int _EXFUN(strtosigno, (const char *__name));
_END_STD_C
#endif /* _STRING_H_ */
+
diff --git a/system/include/libc/sys/resource.h b/system/include/libc/sys/resource.h
index eb827552..fb5d10f2 100644
--- a/system/include/libc/sys/resource.h
+++ b/system/include/libc/sys/resource.h
@@ -7,9 +7,22 @@
#define RUSAGE_CHILDREN -1 /* terminated child processes */
struct rusage {
- struct timeval ru_utime; /* user time used */
- struct timeval ru_stime; /* system time used */
+ struct timeval ru_utime; /* user time used */
+ struct timeval ru_stime; /* system time used */
+ int ru_maxrss; /* XXX Emscripten */
};
+/* XXX Emscripten */
+int getrusage(int who, struct rusage *r_usage);
+
+/* XXX Emscripten */
+#define RLIMIT_CPU 1
+typedef unsigned rlim_t;
+struct rlimit {
+ rlim_t rlim_cur;
+ rlim_t rlim_max;
+};
+int setrlimit(int resource, const struct rlimit *rlim);
+
#endif
diff --git a/system/include/sys/select.h b/system/include/sys/select.h
new file mode 100644
index 00000000..47cef2e5
--- /dev/null
+++ b/system/include/sys/select.h
@@ -0,0 +1,3 @@
+
+int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);
+
diff --git a/tools/shared.py b/tools/shared.py
index bd0e2191..b5903bfe 100644
--- a/tools/shared.py
+++ b/tools/shared.py
@@ -29,15 +29,16 @@ EXEC_LLVM = path_from_root('tools', 'exec_llvm.py')
USE_EMSDK = True
-COMPILER_OPTS = COMPILER_OPTS + ['-m32', '-v', '-U__i386__', '-U__x86_64__', '-U__i386', '-U__x86_64', '-U__SSE__', '-U__SSE2__', '-UX87_DOUBLE_ROUNDING', '-UHAVE_GCC_ASM_FOR_X87', '-DEMSCRIPTEN']
+COMPILER_OPTS = COMPILER_OPTS + ['-m32', '-v', '-U__i386__', '-U__x86_64__', '-U__i386', '-U__x86_64', '-U__SSE__', '-U__SSE2__', '-U__MMX__', '-UX87_DOUBLE_ROUNDING', '-UHAVE_GCC_ASM_FOR_X87', '-DEMSCRIPTEN']
if USE_EMSDK:
COMPILER_OPTS += [ '-nostdinc',
'-I' + path_from_root('system', 'include'),
- '-I' + path_from_root('system', 'include', 'freebsd'), # posix stuff
+ '-I' + path_from_root('system', 'include', 'bsd'), # posix stuff
'-I' + path_from_root('system', 'include', 'libc'),
'-I' + path_from_root('system', 'include', 'libcxx'),
'-I' + path_from_root('system', 'include', 'net'),
+ '-I' + path_from_root('system', 'include', 'SDL'),
]
# Engine tweaks