Make fixes, improvements, and chibicc python bindings

- python now mixes audio 10x faster
- python octal notation is restored
- chibicc now builds code 3x faster
- chibicc now has help documentation
- chibicc can now generate basic python bindings
- linenoise now supports some paredit-like features

See #141
This commit is contained in:
Justine Tunney 2021-10-08 08:11:51 -07:00
parent 28997f3acb
commit 7061c79c22
121 changed files with 5272 additions and 1928 deletions

View file

@ -28,7 +28,6 @@
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "libc/fmt/fmt.h"
#include "libc/log/libfatal.internal.h"
#include "third_party/python/Include/abstract.h"
#include "third_party/python/Include/boolobject.h"
#include "third_party/python/Include/complexobject.h"

View file

@ -1,6 +1,5 @@
#ifndef UMODARITH_H
#define UMODARITH_H
#include "libc/log/libfatal.internal.h"
#include "third_party/python/Modules/_decimal/libmpdec/constants.h"
#include "third_party/python/Modules/_decimal/libmpdec/mpdecimal.h"
#include "third_party/python/Modules/_decimal/libmpdec/typearith.h"

View file

@ -18,7 +18,6 @@
#define PY_SSIZE_T_CLEAN
#include "libc/calls/calls.h"
#include "libc/log/backtrace.internal.h"
#include "libc/log/libfatal.internal.h"
#include "libc/macros.internal.h"
#include "libc/runtime/runtime.h"
#include "libc/stdio/stdio.h"
@ -27,7 +26,6 @@
#include "third_party/mbedtls/md.h"
#include "third_party/mbedtls/pkcs5.h"
#include "third_party/python/Include/Python.h"
#include "third_party/python/Include/ezprint.h"
#include "third_party/python/Include/import.h"
#include "third_party/python/Include/object.h"
#include "third_party/python/Include/pyerrors.h"

View file

@ -1629,7 +1629,7 @@ getargs_u(PyObject *self, PyObject *args)
Py_ssize_t size;
if (!PyArg_ParseTuple(args, "u", &str))
return NULL;
size = Py_UNICODE_strlen(str);
size = wcslen(str);
return PyUnicode_FromUnicode(str, size);
}
@ -1651,7 +1651,7 @@ getargs_Z(PyObject *self, PyObject *args)
if (!PyArg_ParseTuple(args, "Z", &str))
return NULL;
if (str != NULL) {
size = Py_UNICODE_strlen(str);
size = wcslen(str);
return PyUnicode_FromUnicode(str, size);
} else
Py_RETURN_NONE;

View file

@ -849,7 +849,34 @@ audioop_add_impl(PyObject *module, Py_buffer *fragment1,
if (rv == NULL)
return NULL;
ncp = (signed char *)PyBytes_AsString(rv);
for (i = 0; i < fragment1->len; i += width) {
i = 0;
#if defined(__GNUC__) && defined(__SSE2__)
/* [jart] make audio mixing 20x faster */
if (width == 2) {
for (; i + 16 <= fragment1->len; i += 16) {
asm("movups\t%1,%%xmm0\n\t"
"movups\t%2,%%xmm1\n\t"
"paddsw\t%%xmm1,%%xmm0\n\t"
"movups\t%%xmm0,%0"
: "=m"(*(char(*)[16])(ncp + i))
: "m"(*(char(*)[16])((char *)fragment1->buf + i)),
"m"(*(char(*)[16])((char *)fragment2->buf + i))
: "xmm0", "xmm1");
}
} else if (width == 1) {
for (; i + 16 <= fragment1->len; i += 16) {
asm("movups\t%1,%%xmm0\n\t"
"movups\t%2,%%xmm1\n\t"
"paddsb\t%%xmm1,%%xmm0\n\t"
"movups\t%%xmm0,%0"
: "=m"(*(char(*)[16])(ncp + i))
: "m"(*(char(*)[16])((char *)fragment1->buf + i)),
"m"(*(char(*)[16])((char *)fragment2->buf + i))
: "xmm0", "xmm1");
}
}
#endif
for (; i < fragment1->len; i += width) {
int val1 = GETRAWSAMPLE(width, fragment1->buf, i);
int val2 = GETRAWSAMPLE(width, fragment2->buf, i);
if (width < 4) {

View file

@ -19,7 +19,6 @@
#include "libc/assert.h"
#include "libc/calls/calls.h"
#include "libc/errno.h"
#include "libc/log/libfatal.internal.h"
#include "libc/macros.internal.h"
#include "libc/runtime/gc.internal.h"
#include "libc/str/str.h"