├── .emacs.d ├── catppuccin.el ├── init.el └── ip.el ├── .gitignore ├── .gitmodules ├── LICENSE ├── README.md ├── make_emacs_rootfs.sh ├── patch ├── emacs │ └── hash_name_collision.patch └── ffmpeg │ └── fix-build-flags.patch ├── setup_emacs_rootfs.sh └── shutdown └── shutdown.c /.emacs.d/catppuccin.el: -------------------------------------------------------------------------------- 1 | (defun catppuccin-colors () 2 | (write-region (concat (char-to-string 27) "]P" "0" "1e1e2e" "\n") nil "/dev/console" t) 3 | (write-region (concat (char-to-string 27) "]P" "8" "45475a" "\n") nil "/dev/console" t) 4 | (write-region (concat (char-to-string 27) "]P" "1" "f38ba8" "\n") nil "/dev/console" t) 5 | (write-region (concat (char-to-string 27) "]P" "9" "eba0ac" "\n") nil "/dev/console" t) 6 | (write-region (concat (char-to-string 27) "]P" "2" "a6e3a1" "\n") nil "/dev/console" t) 7 | (write-region (concat (char-to-string 27) "]P" "A" "a6e3a1" "\n") nil "/dev/console" t) 8 | (write-region (concat (char-to-string 27) "]P" "3" "fab387" "\n") nil "/dev/console" t) 9 | (write-region (concat (char-to-string 27) "]P" "B" "f9e2af" "\n") nil "/dev/console" t) 10 | (write-region (concat (char-to-string 27) "]P" "4" "89b4f4" "\n") nil "/dev/console" t) 11 | (write-region (concat (char-to-string 27) "]P" "C" "74c7ec" "\n") nil "/dev/console" t) 12 | (write-region (concat (char-to-string 27) "]P" "5" "cba6f7" "\n") nil "/dev/console" t) 13 | (write-region (concat (char-to-string 27) "]P" "D" "b4befe" "\n") nil "/dev/console" t) 14 | (write-region (concat (char-to-string 27) "]P" "6" "89dceb" "\n") nil "/dev/console" t) 15 | (write-region (concat (char-to-string 27) "]P" "E" "94e2d5" "\n") nil "/dev/console" t) 16 | (write-region (concat (char-to-string 27) "]P" "7" "cdd6f4" "\n") nil "/dev/console" t) 17 | (write-region (concat (char-to-string 27) "]P" "F" "9399b2" "\n") nil "/dev/console" t) 18 | t) 19 | 20 | (provide 'catppuccin) 21 | -------------------------------------------------------------------------------- /.emacs.d/init.el: -------------------------------------------------------------------------------- 1 | ;;; init.el --- Emacs-OS Init System -*- lexical-binding: t; -*- 2 | ;; 3 | ;; Copyright (C) 2022 Carsten Kragelund 4 | ;; 5 | ;; Author: Carsten Kragelund 6 | ;; Maintainer: Carsten Kragelund 7 | ;; Created: December 16, 2022 8 | ;; Modified: December 16, 2022 9 | ;; Version: 1.0.0 10 | ;; Keywords: abbrev bib c calendar comm convenience data docs emulations extensions faces files frames games hardware help hypermedia i18n internal languages lisp local maint mail matching mouse multimedia news outlines processes terminals tex tools unix vc wp 11 | ;; Homepage: https://github.com/nyxkrage/emacs-os 12 | ;; Package-Requires: ((emacs "24.3")) 13 | ;; 14 | ;; This file is not part of GNU Emacs. 15 | ;; 16 | ;;; Commentary: 17 | ;; 18 | ;; This is the Emacs-OS init.el file which sets up reboot and shutdown commands 19 | ;; and makes sure that the root filesystem gets mounted as rw 20 | ;; 21 | ;;; Code: 22 | 23 | (message "init starting") 24 | (setq auto-save-interval 0) 25 | 26 | (defun save-all-buffers () 27 | (save-some-buffers nil t)) 28 | 29 | (defun reboot () 30 | (interactive) 31 | (when (yes-or-no-p "Really reboot the system? ") 32 | (save-all-buffers) 33 | (if (file-exists-p "/etc/mtab") (delete-file "/etc/mtab")) 34 | (call-process "/sbin/mount" nil nil nil "-n" "-o" "ro,remount" "/") 35 | (call-process "/sbin/reboot" nil nil nil))) 36 | 37 | (defun shutdown () 38 | (interactive) 39 | (when (yes-or-no-p "Really shut down the system? ") 40 | (save-all-buffers) 41 | (if (file-exists-p "/etc/mtab") (delete-file "/etc/mtab")) 42 | (call-process "/sbin/mount" nil nil nil "-n" "-o" "ro,remount" "/") 43 | (call-process "/sbin/shutdown" nil nil nil))) 44 | 45 | ;; Global keybindings 46 | (global-set-key "\C-x\C-z" 'reboot) 47 | (global-set-key "\C-x\C-c" 'shutdown) 48 | (global-set-key "\C-\M-s" 'eshell) 49 | 50 | (global-set-key "^" 'keyboard-quit) ;; strangely, C-g does not work. 51 | 52 | ;; Add some standard directories to exec-path to use in eshell 53 | (setenv "PATH" "/bin:/sbin") 54 | (add-to-list 'load-path "/.emacs.d/") 55 | 56 | ;; Mount various needed virtual/tmp filesystem 57 | (call-process "/sbin/mount" nil "*log*" nil "-t" "proc" "proc" "/proc") 58 | (call-process "/sbin/mount" nil "*log*" nil "-o" "rw,remount" "/") 59 | (call-process "/sbin/mount" nil "*log*" nil "-t" "sysfs" "sys" "/sys") 60 | (call-process "/sbin/mount" nil "*log*" nil "-t" "tmpfs" "run" "/run") 61 | (call-process "/sbin/mount" nil "*log*" nil "-t" "devtmpfs" "dev" "/dev") 62 | 63 | (call-process "/bin/hostname" nil nil nil "emacs") 64 | 65 | (require 'ip) 66 | (assign-ip '(172 16 57 10) "ens33") 67 | 68 | (custom-set-variables 69 | '(inhibit-startup-screen t) 70 | '(initial-buffer-choice nil)) 71 | 72 | (message "init done") 73 | 74 | (require 'catppuccin) 75 | 76 | (catppuccin-colors) 77 | 78 | (eshell) 79 | 80 | (provide 'init) 81 | ;;; init.el ends here 82 | -------------------------------------------------------------------------------- /.emacs.d/ip.el: -------------------------------------------------------------------------------- 1 | (defun ip-to-string (ip) 2 | (mapconcat 'int-to-string ip ".")) 3 | 4 | (defun modify-ip (ip idx newval) 5 | (let ((i (copy-tree ip))) 6 | (setcar (nthcdr idx i) newval) 7 | i)) 8 | 9 | (defun assign-ip (ip interface) 10 | (call-process "/sbin/ip" nil "*log*" nil 11 | "addr" 12 | "add" 13 | (concat (ip-to-string ip) "/24") 14 | "broadcast" 15 | (ip-to-string (modify-ip ip 3 255)) 16 | "dev" 17 | interface) 18 | (call-process "/sbin/ip" nil "*log*" nil 19 | "link" 20 | "set" 21 | "dev" 22 | interface 23 | "up") 24 | (call-process "/sbin/ip" nil "*log*" nil 25 | "route" 26 | "add" 27 | "default" 28 | "via" 29 | (ip-to-string (modify-ip ip 3 2)) 30 | "dev" 31 | interface)) 32 | 33 | (provide 'ip) 34 | 35 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .idea 3 | *.log 4 | tmp/ 5 | 6 | rootfs 7 | rootfs_mnt/ 8 | shutdown/shutdown 9 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "util-linux"] 2 | path = util-linux 3 | url = https://github.com/util-linux/util-linux 4 | [submodule "emacs"] 5 | path = emacs 6 | url = https://github.com/emacs-mirror/emacs 7 | [submodule "linux"] 8 | path = linux 9 | url = https://github.com/torvalds/linux 10 | [submodule "ncurses"] 11 | path = ncurses 12 | url = https://github.com/mirror/ncurses 13 | [submodule "busybox"] 14 | path = busybox 15 | url = https://github.com/mirror/busybox 16 | [submodule "libxml2"] 17 | path = libxml2 18 | url = https://github.com/GNOME/libxml2.git 19 | [submodule "gnutls"] 20 | path = gnutls 21 | url = https://github.com/gnutls/gnutls.git 22 | [submodule "nettle"] 23 | path = nettle 24 | url = https://github.com/gnutls/nettle.git 25 | [submodule "libev"] 26 | path = libev 27 | url = https://github.com/enki/libev.git 28 | [submodule "ffmpeg"] 29 | path = ffmpeg 30 | url = https://github.com/zimbatm/ffmpeg-static 31 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2022 Carsten Kragelund 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Emacs running directly on Linux (Pid1) 2 | 3 | ## Setup prerequisites 4 | 5 | ``` shellsession 6 | $ export ROOTFS_MNT=$PWD/rootfs_mnt 7 | $ export ROOTFS=$PWD/rootfs 8 | $ ./make_emacs_rootfs.sh 9 | ``` 10 | 11 | ## Statically compiled Ncurses 12 | Emacs will complain about not being able to find tputs, unless a statically linked library of `ncurses` can be found 13 | ``` shellsession 14 | $ pushd ncurses 15 | $ ./configure CC=gcc CXX=gcc LDFLAGS=-static CFLAGS=-static --prefix="" 16 | $ make -j$(nproc) 17 | $ make DESTDIR=$PWD/build install 18 | $ popd 19 | ``` 20 | 21 | ## Statically compiled libxml2 22 | The Emacs web browser requires libxml2 to work 23 | 24 | ``` shellsession 25 | $ pushd libxml2 26 | $ cmake -DBUILD_SHARED_LIBS=OFF -DLIBXML2_WITH_LZMA=OFF -DLIBXML2_WITH_ZLIB=OFF -DLIBXML_HTTP_ENABLED=OFF -DCMAKE_INSTALL_PREFIX:PATH=$PWD/build . 27 | $ sudo cmake --build . --target install 28 | $ popd 29 | ``` 30 | 31 | ## Statically compiled nettle 32 | Nettle is a cryptograpy library used by gnutls 33 | 34 | ``` shellsession 35 | $ pushd nettle 36 | $ ./configure CC=musl-gcc --prefix=$PWD/build --enable-static --disable-documentation --disable-shared --enable-mini-gmp 37 | $ make -j$(nproc) 38 | $ make install 39 | $ popd 40 | ``` 41 | 42 | ## Statically compiled libev 43 | Libev is an event loop library required by gnutls 44 | 45 | ``` shellsession 46 | $ pushd libev 47 | $ ./configure CC=musl-gcc CXX=musl-gcc --prefix=$PWD/build --enable-static --enable-shared=no 48 | $ make -j$(nproc) 49 | $ make install 50 | $ popd 51 | ``` 52 | 53 | ## Statically compiled gnutls 54 | The Emacs web browser requires gnutls support to connect to https websites 55 | 56 | ``` shellsession 57 | $ pushd gnutls 58 | $ ./bootstrap 59 | $ ./configure CC=musl-gcc NETTLE_CFLAGS="-I$PWD/../nettle/build/include" NETTLE_LIBS="-static -L$PWD/../nettle/build/lib64 -lhogweed -lnettle" HOGWEED_CFLAGS="-I$PWD/../nettle/build/include" HOGWEED_LIBS="-static -L$PWD/../nettle/build/lib64 -lhogweed -lnettle" LDFLAGS="-static -L$PWD/../nettle/build/lib64 -lhogweed -lnettle" CFLAGS="-I$PWD/../nettle/build/include" --with-libev-prefix="$PWD/../libev/build" --prefix=$PWD/build --enable-static --disable-shared --with-included-unistring --with-included-libtasn1 --disable-cxx --without-p11-kit --without-idn --disable-doc --disable-gost --with-nettle-mini 60 | $ make -j$(nproc) 61 | $ make install 62 | $ popd 63 | ``` 64 | 65 | ## Statically compiled Emacs 66 | We need a statically compiled version of emacs if we want to keep the rootfs minimal 67 | 68 | ``` shellsession 69 | $ pushd emacs 70 | $ git apply ../patches/emacs/*.patch 71 | $ ./autogen.sh 72 | $ ./configure --with-json=no --without-x --without-libsystemd --with-sound=no --without-lcms2 --without-dbus CFLAGS="-O3 -I$PWD/../ncurses/build/include" LIBGNUTLS_CFLAGS="-I$PWD/../nettle/build/include -I$PWD/../gnutls/build/include" LIBXML2_CFLAGS="-I$PWD/../libxml2/build/include/libxml2" LDFLAGS="-static -L$PWD/../ncurses/build/lib" LIBXML2_LIBS="-static -L$PWD/../libxml2/build/lib -lxml2" LIBGNUTLS_LIBS="-static -L$PWD/../nettle/build/lib64 -L$PWD/../gnutls/build/lib -lgnutls -lhogweed -lnettle" CC=musl-gcc CXX=musl-gcc --prefix="" 73 | $ make -j$(nproc) 74 | $ sudo make DESTDIR=$ROOTFS_MNT install 75 | $ popd 76 | ``` 77 | 78 | # User Mode Linux 79 | This is not strictly necessary and you can also use a virtual machine instead, but this makes for a much faster workflow 80 | 81 | ``` shellsession 82 | $ pushd Linux 83 | $ make ARCH=um menuconfig 84 | $ make ARCH=um -j$(nproc) 85 | $ install -m 755 linux $HOME/.local/bin/uml 86 | $ popd 87 | ``` 88 | 89 | # Statically compile busybox 90 | 91 | When creating your busybox config the following settings must be set correctly 92 | 93 | [x] Settings->Don't use /usr 94 | [x] Settings->Build static binary (no shared libs) 95 | [x] Linux System Utilities->mount 96 | [x] Linux System Utilities->umount 97 | [x] Login/Password Management Utilities->getty 98 | 99 | ``` shellsession 100 | $ pushd busybox 101 | $ make menuconfig 102 | $ make -j$(nproc) 103 | $ make install 104 | $ popd 105 | ``` 106 | 107 | # Shutdown and Reboot utilities 108 | 109 | ``` shellsession 110 | $ pushd shutdown 111 | $ gcc -static shutdown.c -o shutdown 112 | $ popd 113 | ``` 114 | 115 | # Statically compiled ffmpeg 116 | This allows the ability to record the framebuffer and to stream to twitch 117 | 118 | ``` shellsession 119 | $ pushd twitch 120 | $ git apply ../patches/ffmpeg/*.patch 121 | $ ./build.sh -j$(nproc) 122 | $ popd 123 | ``` 124 | 125 | 126 | # Finishing steps 127 | 128 | ``` shellsession 129 | $ ./setup_emacs_rootfs.sh 130 | $ sudo umount $ROOTFS_MNT 131 | ``` 132 | 133 | # Launch Emacs-Os 134 | 135 | ``` shellsession 136 | $ uml ubd0=$ROOTFS init=/sbin/getty -i -n -l /bin/emacs 0 /dev/tty0 linux 137 | ``` 138 | -------------------------------------------------------------------------------- /make_emacs_rootfs.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | rfs_mkdir() { 4 | echo "$@" | tr ' ' '\n' | xargs -I{} sudo mkdir -p "$ROOTFS_MNT/{}" 5 | } 6 | 7 | SIZE=${1:-500M} 8 | SIZE=$(numfmt --from=iec $SIZE) 9 | 10 | dd if=/dev/urandom of=$ROOTFS status=progress count=$(($SIZE / 10000000)) bs=10M 11 | mke2fs $ROOTFS 12 | mkdir -p $ROOTFS_MNT 13 | sudo mount -o loop $ROOTFS $ROOTFS_MNT 14 | 15 | rfs_mkdir bin/ boot/ dev/ etc/ lib/ proc/ run/ sbin/ sys/ tmp/ 16 | sudo ln -s . "$ROOTFS_MNT/usr" 17 | sudo mknod -m 600 "$ROOTFS_MNT/dev/console" c 5 1 18 | sudo mknod -m 666 "$ROOTFS_MNT/dev/null" c 1 3 19 | -------------------------------------------------------------------------------- /patch/emacs/hash_name_collision.patch: -------------------------------------------------------------------------------- 1 | diff --git a/src/ChangeLog.12 b/src/ChangeLog.12 2 | index f455c4de38..633e7e6c4e 100644 3 | --- a/src/ChangeLog.12 4 | +++ b/src/ChangeLog.12 5 | @@ -3220,7 +3220,7 @@ 6 | 7 | 2012-11-08 Paul Eggert 8 | 9 | - Use same hash function for hashfn_profiler as for hash_string etc. 10 | + Use same hash function for hashfn_profiler as for lisp_hash_string etc. 11 | * fns.c (SXHASH_COMBINE): Remove. All uses replaced by sxhash_combine. 12 | * lisp.h (sxhash_combine): New inline function, with the contents 13 | of the old SXHASH_COMBINE. 14 | diff --git a/src/bytecode.c b/src/bytecode.c 15 | index c765e1be2b..4f2aee81ac 100644 16 | --- a/src/bytecode.c 17 | +++ b/src/bytecode.c 18 | @@ -1701,7 +1701,7 @@ #define DEFINE(name, value) [name] = &&insn_ ## name, 19 | break; 20 | } 21 | else 22 | - i = hash_lookup (h, v1, NULL); 23 | + i = lisp_hash_lookup (h, v1, NULL); 24 | 25 | if (i >= 0) 26 | { 27 | diff --git a/src/category.c b/src/category.c 28 | index bedde0de45..396a33ae29 100644 29 | --- a/src/category.c 30 | +++ b/src/category.c 31 | @@ -56,7 +56,7 @@ hash_get_category_set (Lisp_Object table, Lisp_Object category_set) 32 | Qnil, false)); 33 | struct Lisp_Hash_Table *h = XHASH_TABLE (XCHAR_TABLE (table)->extras[1]); 34 | Lisp_Object hash; 35 | - ptrdiff_t i = hash_lookup (h, category_set, &hash); 36 | + ptrdiff_t i = lisp_hash_lookup (h, category_set, &hash); 37 | if (i >= 0) 38 | return HASH_KEY (h, i); 39 | hash_put (h, category_set, Qnil, hash); 40 | diff --git a/src/ccl.c b/src/ccl.c 41 | index 1a4f73500a..3496685225 100644 42 | --- a/src/ccl.c 43 | +++ b/src/ccl.c 44 | @@ -1372,7 +1372,7 @@ #define EXCMD (field1 >> 6) 45 | 46 | eop = (FIXNUM_OVERFLOW_P (reg[RRR]) 47 | ? -1 48 | - : hash_lookup (h, make_fixnum (reg[RRR]), NULL)); 49 | + : lisp_hash_lookup (h, make_fixnum (reg[RRR]), NULL)); 50 | if (eop >= 0) 51 | { 52 | Lisp_Object opl; 53 | @@ -1401,7 +1401,7 @@ #define EXCMD (field1 >> 6) 54 | 55 | eop = (FIXNUM_OVERFLOW_P (i) 56 | ? -1 57 | - : hash_lookup (h, make_fixnum (i), NULL)); 58 | + : lisp_hash_lookup (h, make_fixnum (i), NULL)); 59 | if (eop >= 0) 60 | { 61 | Lisp_Object opl; 62 | diff --git a/src/charset.c b/src/charset.c 63 | index bb59262fe9..de8789c328 100644 64 | --- a/src/charset.c 65 | +++ b/src/charset.c 66 | @@ -1107,7 +1107,7 @@ DEFUN ("define-charset-internal", Fdefine_charset_internal, 67 | CHECK_LIST (args[charset_arg_plist]); 68 | ASET (attrs, charset_plist, args[charset_arg_plist]); 69 | 70 | - charset.hash_index = hash_lookup (hash_table, args[charset_arg_name], 71 | + charset.hash_index = lisp_hash_lookup (hash_table, args[charset_arg_name], 72 | &hash_code); 73 | if (charset.hash_index >= 0) 74 | { 75 | diff --git a/src/charset.h b/src/charset.h 76 | index 4f4a14f1bd..4a9fc6c7e7 100644 77 | --- a/src/charset.h 78 | +++ b/src/charset.h 79 | @@ -286,7 +286,7 @@ #define CHARSET_SYMBOL_ID(symbol) \ 80 | /* Return an index to Vcharset_hash_table of the charset whose symbol 81 | is SYMBOL. */ 82 | #define CHARSET_SYMBOL_HASH_INDEX(symbol) \ 83 | - hash_lookup (XHASH_TABLE (Vcharset_hash_table), symbol, NULL) 84 | + lisp_hash_lookup (XHASH_TABLE (Vcharset_hash_table), symbol, NULL) 85 | 86 | /* Return the attribute vector of CHARSET. */ 87 | #define CHARSET_ATTRIBUTES(charset) \ 88 | diff --git a/src/coding.h b/src/coding.h 89 | index d86c17d18b..605874ad1c 100644 90 | --- a/src/coding.h 91 | +++ b/src/coding.h 92 | @@ -193,7 +193,7 @@ #define CODING_SYSTEM_SPEC(coding_system_symbol) \ 93 | /* Return the ID of CODING_SYSTEM_SYMBOL. */ 94 | 95 | #define CODING_SYSTEM_ID(coding_system_symbol) \ 96 | - hash_lookup (XHASH_TABLE (Vcoding_system_hash_table), \ 97 | + lisp_hash_lookup (XHASH_TABLE (Vcoding_system_hash_table), \ 98 | coding_system_symbol, NULL) 99 | 100 | /* Return true if CODING_SYSTEM_SYMBOL is a coding system. */ 101 | diff --git a/src/composite.c b/src/composite.c 102 | index 6b256171ac..5e3d6cf514 100644 103 | --- a/src/composite.c 104 | +++ b/src/composite.c 105 | @@ -240,7 +240,7 @@ get_composition_id (ptrdiff_t charpos, ptrdiff_t bytepos, ptrdiff_t nchars, 106 | else 107 | goto invalid_composition; 108 | 109 | - hash_index = hash_lookup (hash_table, key, &hash_code); 110 | + hash_index = lisp_hash_lookup (hash_table, key, &hash_code); 111 | if (hash_index >= 0) 112 | { 113 | /* We have already registered the same composition. Change PROP 114 | @@ -643,7 +643,7 @@ compose_text (ptrdiff_t start, ptrdiff_t end, Lisp_Object components, 115 | composition_gstring_lookup_cache (Lisp_Object header) 116 | { 117 | struct Lisp_Hash_Table *h = XHASH_TABLE (gstring_hash_table); 118 | - ptrdiff_t i = hash_lookup (h, header, NULL); 119 | + ptrdiff_t i = lisp_hash_lookup (h, header, NULL); 120 | 121 | return (i >= 0 ? HASH_VALUE (h, i) : Qnil); 122 | } 123 | diff --git a/src/emacs-module.c b/src/emacs-module.c 124 | index 35d6e9e0d7..64b8d68c82 100644 125 | --- a/src/emacs-module.c 126 | +++ b/src/emacs-module.c 127 | @@ -426,7 +426,7 @@ module_make_global_ref (emacs_env *env, emacs_value value) 128 | MODULE_FUNCTION_BEGIN (NULL); 129 | struct Lisp_Hash_Table *h = XHASH_TABLE (Vmodule_refs_hash); 130 | Lisp_Object new_obj = value_to_lisp (value), hashcode; 131 | - ptrdiff_t i = hash_lookup (h, new_obj, &hashcode); 132 | + ptrdiff_t i = lisp_hash_lookup (h, new_obj, &hashcode); 133 | 134 | /* Note: This approach requires the garbage collector to never move 135 | objects. */ 136 | @@ -463,7 +463,7 @@ module_free_global_ref (emacs_env *env, emacs_value global_value) 137 | MODULE_FUNCTION_BEGIN (); 138 | struct Lisp_Hash_Table *h = XHASH_TABLE (Vmodule_refs_hash); 139 | Lisp_Object obj = value_to_lisp (global_value); 140 | - ptrdiff_t i = hash_lookup (h, obj, NULL); 141 | + ptrdiff_t i = lisp_hash_lookup (h, obj, NULL); 142 | 143 | if (module_assertions) 144 | { 145 | diff --git a/src/fns.c b/src/fns.c 146 | index eeb65cadf3..c29d0bb658 100644 147 | --- a/src/fns.c 148 | +++ b/src/fns.c 149 | @@ -2730,7 +2730,7 @@ internal_equal (Lisp_Object o1, Lisp_Object o2, enum equal_kind equal_kind, 150 | { 151 | struct Lisp_Hash_Table *h = XHASH_TABLE (ht); 152 | Lisp_Object hash; 153 | - ptrdiff_t i = hash_lookup (h, o1, &hash); 154 | + ptrdiff_t i = lisp_hash_lookup (h, o1, &hash); 155 | if (i >= 0) 156 | { /* `o1' was seen already. */ 157 | Lisp_Object o2s = HASH_VALUE (h, i); 158 | @@ -4678,7 +4678,7 @@ hash_table_rehash (Lisp_Object hash) 159 | matching KEY, or -1 if not found. */ 160 | 161 | ptrdiff_t 162 | -hash_lookup (struct Lisp_Hash_Table *h, Lisp_Object key, Lisp_Object *hash) 163 | +lisp_hash_lookup (struct Lisp_Hash_Table *h, Lisp_Object key, Lisp_Object *hash) 164 | { 165 | ptrdiff_t start_of_bucket, i; 166 | 167 | @@ -4928,7 +4928,7 @@ #define SXHASH_MAX_LEN 7 168 | can be any EMACS_UINT value. */ 169 | 170 | EMACS_UINT 171 | -hash_string (char const *ptr, ptrdiff_t len) 172 | +lisp_hash_string (char const *ptr, ptrdiff_t len) 173 | { 174 | char const *p = ptr; 175 | char const *end = ptr + len; 176 | @@ -4964,7 +4964,7 @@ hash_string (char const *ptr, ptrdiff_t len) 177 | static EMACS_UINT 178 | sxhash_string (char const *ptr, ptrdiff_t len) 179 | { 180 | - EMACS_UINT hash = hash_string (ptr, len); 181 | + EMACS_UINT hash = lisp_hash_string (ptr, len); 182 | return SXHASH_REDUCE (hash); 183 | } 184 | 185 | @@ -5430,7 +5430,7 @@ DEFUN ("gethash", Fgethash, Sgethash, 2, 3, 0, 186 | (Lisp_Object key, Lisp_Object table, Lisp_Object dflt) 187 | { 188 | struct Lisp_Hash_Table *h = check_hash_table (table); 189 | - ptrdiff_t i = hash_lookup (h, key, NULL); 190 | + ptrdiff_t i = lisp_hash_lookup (h, key, NULL); 191 | return i >= 0 ? HASH_VALUE (h, i) : dflt; 192 | } 193 | 194 | @@ -5445,7 +5445,7 @@ DEFUN ("puthash", Fputhash, Sputhash, 3, 3, 0, 195 | check_mutable_hash_table (table, h); 196 | 197 | Lisp_Object hash; 198 | - ptrdiff_t i = hash_lookup (h, key, &hash); 199 | + ptrdiff_t i = lisp_hash_lookup (h, key, &hash); 200 | if (i >= 0) 201 | set_hash_value_slot (h, i, value); 202 | else 203 | diff --git a/src/haiku_font_support.cc b/src/haiku_font_support.cc 204 | index 9a2492c9a1..2e29ff3130 100644 205 | --- a/src/haiku_font_support.cc 206 | +++ b/src/haiku_font_support.cc 207 | @@ -121,7 +121,7 @@ cache_font_object_data (const char *family, const char *style, 208 | uint32_t hash; 209 | struct font_object_cache_bucket *bucket, *next; 210 | 211 | - hash = hash_string (family) ^ hash_string (style); 212 | + hash = lisp_hash_string (family) ^ lisp_hash_string (style); 213 | bucket = font_object_cache[hash % 2048]; 214 | 215 | for (next = bucket; next; next = next->next) 216 | @@ -149,7 +149,7 @@ lookup_font_object_data (const char *family, const char *style) 217 | uint32_t hash; 218 | struct font_object_cache_bucket *bucket, *next; 219 | 220 | - hash = hash_string (family) ^ hash_string (style); 221 | + hash = lisp_hash_string (family) ^ lisp_hash_string (style); 222 | bucket = font_object_cache[hash % 2048]; 223 | 224 | for (next = bucket; next; next = next->next) 225 | diff --git a/src/image.c b/src/image.c 226 | index b881e43e95..12703252c6 100644 227 | --- a/src/image.c 228 | +++ b/src/image.c 229 | @@ -4795,7 +4795,7 @@ xpm_free_color_cache (void) 230 | static int 231 | xpm_color_bucket (char *color_name) 232 | { 233 | - EMACS_UINT hash = hash_string (color_name, strlen (color_name)); 234 | + EMACS_UINT hash = lisp_hash_string (color_name, strlen (color_name)); 235 | return hash % XPM_COLOR_CACHE_BUCKETS; 236 | } 237 | 238 | @@ -5481,7 +5481,7 @@ xpm_put_color_table_h (Lisp_Object color_table, 239 | struct Lisp_Hash_Table *table = XHASH_TABLE (color_table); 240 | Lisp_Object chars = make_unibyte_string (chars_start, chars_len), hash_code; 241 | 242 | - hash_lookup (table, chars, &hash_code); 243 | + lisp_hash_lookup (table, chars, &hash_code); 244 | hash_put (table, chars, color, hash_code); 245 | } 246 | 247 | @@ -5492,7 +5492,7 @@ xpm_get_color_table_h (Lisp_Object color_table, 248 | { 249 | struct Lisp_Hash_Table *table = XHASH_TABLE (color_table); 250 | ptrdiff_t i = 251 | - hash_lookup (table, make_unibyte_string (chars_start, chars_len), NULL); 252 | + lisp_hash_lookup (table, make_unibyte_string (chars_start, chars_len), NULL); 253 | 254 | return i >= 0 ? HASH_VALUE (table, i) : Qnil; 255 | } 256 | diff --git a/src/json.c b/src/json.c 257 | index cdcc11358e..55c67b9c2f 100644 258 | --- a/src/json.c 259 | +++ b/src/json.c 260 | @@ -864,7 +864,7 @@ json_to_lisp (json_t *json, const struct json_configuration *conf) 261 | json_object_foreach (json, key_str, value) 262 | { 263 | Lisp_Object key = build_string_from_utf8 (key_str), hash; 264 | - ptrdiff_t i = hash_lookup (h, key, &hash); 265 | + ptrdiff_t i = lisp_hash_lookup (h, key, &hash); 266 | /* Keys in JSON objects are unique, so the key can't 267 | be present yet. */ 268 | eassert (i < 0); 269 | diff --git a/src/lisp.h b/src/lisp.h 270 | index be511a0eb9..c26859a2be 100644 271 | --- a/src/lisp.h 272 | +++ b/src/lisp.h 273 | @@ -4018,12 +4018,12 @@ #define CONS_TO_INTEGER(cons, type, var) \ 274 | extern bool sweep_weak_table (struct Lisp_Hash_Table *, bool); 275 | extern void hexbuf_digest (char *, void const *, int); 276 | extern char *extract_data_from_object (Lisp_Object, ptrdiff_t *, ptrdiff_t *); 277 | -EMACS_UINT hash_string (char const *, ptrdiff_t); 278 | +EMACS_UINT lisp_hash_string (char const *, ptrdiff_t); 279 | EMACS_UINT sxhash (Lisp_Object); 280 | Lisp_Object hashfn_user_defined (Lisp_Object, struct Lisp_Hash_Table *); 281 | Lisp_Object make_hash_table (struct hash_table_test, EMACS_INT, float, float, 282 | Lisp_Object, bool); 283 | -ptrdiff_t hash_lookup (struct Lisp_Hash_Table *, Lisp_Object, Lisp_Object *); 284 | +ptrdiff_t lisp_hash_lookup (struct Lisp_Hash_Table *, Lisp_Object, Lisp_Object *); 285 | ptrdiff_t hash_put (struct Lisp_Hash_Table *, Lisp_Object, Lisp_Object, 286 | Lisp_Object); 287 | void hash_remove_from_table (struct Lisp_Hash_Table *, Lisp_Object); 288 | diff --git a/src/lread.c b/src/lread.c 289 | index d838a18de5..523ed595a5 100644 290 | --- a/src/lread.c 291 | +++ b/src/lread.c 292 | @@ -4008,7 +4008,7 @@ read0 (Lisp_Object readcharfun, bool locate_syms) 293 | = XHASH_TABLE (read_objects_map); 294 | Lisp_Object number = make_fixnum (n); 295 | Lisp_Object hash; 296 | - ptrdiff_t i = hash_lookup (h, number, &hash); 297 | + ptrdiff_t i = lisp_hash_lookup (h, number, &hash); 298 | if (i >= 0) 299 | /* Not normal, but input could be malformed. */ 300 | set_hash_value_slot (h, i, placeholder); 301 | @@ -4026,7 +4026,7 @@ read0 (Lisp_Object readcharfun, bool locate_syms) 302 | /* #N# -- reference to numbered object */ 303 | struct Lisp_Hash_Table *h 304 | = XHASH_TABLE (read_objects_map); 305 | - ptrdiff_t i = hash_lookup (h, make_fixnum (n), NULL); 306 | + ptrdiff_t i = lisp_hash_lookup (h, make_fixnum (n), NULL); 307 | if (i < 0) 308 | invalid_syntax ("#", readcharfun); 309 | obj = HASH_VALUE (h, i); 310 | @@ -4324,7 +4324,7 @@ read0 (Lisp_Object readcharfun, bool locate_syms) 311 | struct Lisp_Hash_Table *h2 312 | = XHASH_TABLE (read_objects_completed); 313 | Lisp_Object hash; 314 | - ptrdiff_t i = hash_lookup (h2, placeholder, &hash); 315 | + ptrdiff_t i = lisp_hash_lookup (h2, placeholder, &hash); 316 | eassert (i < 0); 317 | hash_put (h2, placeholder, Qnil, hash); 318 | obj = placeholder; 319 | @@ -4339,7 +4339,7 @@ read0 (Lisp_Object readcharfun, bool locate_syms) 320 | struct Lisp_Hash_Table *h2 321 | = XHASH_TABLE (read_objects_completed); 322 | Lisp_Object hash; 323 | - ptrdiff_t i = hash_lookup (h2, obj, &hash); 324 | + ptrdiff_t i = lisp_hash_lookup (h2, obj, &hash); 325 | eassert (i < 0); 326 | hash_put (h2, obj, Qnil, hash); 327 | } 328 | @@ -4351,7 +4351,7 @@ read0 (Lisp_Object readcharfun, bool locate_syms) 329 | /* ...and #n# will use the real value from now on. */ 330 | struct Lisp_Hash_Table *h = XHASH_TABLE (read_objects_map); 331 | Lisp_Object hash; 332 | - ptrdiff_t i = hash_lookup (h, e->u.numbered.number, &hash); 333 | + ptrdiff_t i = lisp_hash_lookup (h, e->u.numbered.number, &hash); 334 | eassert (i >= 0); 335 | set_hash_value_slot (h, i, obj); 336 | } 337 | @@ -4405,7 +4405,7 @@ substitute_object_recurse (struct subst *subst, Lisp_Object subtree) 338 | by #n=, which means that we can find it as a value in 339 | COMPLETED. */ 340 | if (EQ (subst->completed, Qt) 341 | - || hash_lookup (XHASH_TABLE (subst->completed), subtree, NULL) >= 0) 342 | + || lisp_hash_lookup (XHASH_TABLE (subst->completed), subtree, NULL) >= 0) 343 | subst->seen = Fcons (subtree, subst->seen); 344 | 345 | /* Recurse according to subtree's type. 346 | @@ -4900,7 +4900,7 @@ oblookup (Lisp_Object obarray, register const char *ptr, ptrdiff_t size, ptrdiff 347 | obarray = check_obarray (obarray); 348 | /* This is sometimes needed in the middle of GC. */ 349 | obsize = gc_asize (obarray); 350 | - hash = hash_string (ptr, size_byte) % obsize; 351 | + hash = lisp_hash_string (ptr, size_byte) % obsize; 352 | bucket = AREF (obarray, hash); 353 | oblookup_last_bucket_number = hash; 354 | if (BASE_EQ (bucket, make_fixnum (0))) 355 | diff --git a/src/macfont.m b/src/macfont.m 356 | index 4de056cb36..8b1527cf60 100644 357 | --- a/src/macfont.m 358 | +++ b/src/macfont.m 359 | @@ -983,7 +983,7 @@ static void mac_font_get_glyphs_for_variants (CFDataRef, UTF32Char, 360 | if (HASH_TABLE_P (macfont_family_cache)) 361 | { 362 | struct Lisp_Hash_Table *h = XHASH_TABLE (macfont_family_cache); 363 | - ptrdiff_t i = hash_lookup (h, symbol, NULL); 364 | + ptrdiff_t i = lisp_hash_lookup (h, symbol, NULL); 365 | 366 | if (i >= 0) 367 | { 368 | @@ -1009,7 +1009,7 @@ static void mac_font_get_glyphs_for_variants (CFDataRef, UTF32Char, 369 | macfont_family_cache = CALLN (Fmake_hash_table, QCtest, Qeq); 370 | 371 | h = XHASH_TABLE (macfont_family_cache); 372 | - i = hash_lookup (h, symbol, &hash); 373 | + i = lisp_hash_lookup (h, symbol, &hash); 374 | value = string ? make_mint_ptr ((void *) CFRetain (string)) : Qnil; 375 | if (i >= 0) 376 | { 377 | diff --git a/src/minibuf.c b/src/minibuf.c 378 | index 3f34b1b083..1a892d6787 100644 379 | --- a/src/minibuf.c 380 | +++ b/src/minibuf.c 381 | @@ -2110,7 +2110,7 @@ DEFUN ("test-completion", Ftest_completion, Stest_completion, 2, 3, 0, 382 | else if (HASH_TABLE_P (collection)) 383 | { 384 | struct Lisp_Hash_Table *h = XHASH_TABLE (collection); 385 | - i = hash_lookup (h, string, NULL); 386 | + i = lisp_hash_lookup (h, string, NULL); 387 | if (i >= 0) 388 | { 389 | tem = HASH_KEY (h, i); 390 | diff --git a/src/profiler.c b/src/profiler.c 391 | index 5cb42d54fa..6a7eb49768 100644 392 | --- a/src/profiler.c 393 | +++ b/src/profiler.c 394 | @@ -166,7 +166,7 @@ record_backtrace (log_t *log, EMACS_INT count) 395 | handler, and we optimize the code to try and avoid computing the 396 | hash+lookup twice. See fns.c:Fputhash for reference. */ 397 | Lisp_Object hash; 398 | - ptrdiff_t j = hash_lookup (log, backtrace, &hash); 399 | + ptrdiff_t j = lisp_hash_lookup (log, backtrace, &hash); 400 | if (j >= 0) 401 | { 402 | EMACS_INT old_val = XFIXNUM (HASH_VALUE (log, j)); 403 | -------------------------------------------------------------------------------- /patch/ffmpeg/fix-build-flags.patch: -------------------------------------------------------------------------------- 1 | diff --git a/build.sh b/build.sh 2 | index 5199d9b..5a4a661 100755 3 | --- a/build.sh 4 | +++ b/build.sh 5 | @@ -273,7 +273,7 @@ cd $BUILD_DIR/x265* 6 | cd build/linux 7 | [ $rebuild -eq 1 ] && find . -mindepth 1 ! -name 'make-Makefiles.bash' -and ! -name 'multilib.sh' -exec rm -r {} + 8 | PATH="$BIN_DIR:$PATH" cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$TARGET_DIR" -DENABLE_SHARED:BOOL=OFF -DSTATIC_LINK_CRT:BOOL=ON -DENABLE_CLI:BOOL=OFF ../../source 9 | -sed -i '' 's/-lgcc_s/-lgcc_eh/g' x265.pc 10 | +sed -i 's/-lgcc_s/-lgcc_eh/g' x265.pc 11 | make -j $jval 12 | make install 13 | 14 | @@ -341,7 +341,7 @@ if [ "$platform" = "linux" ]; then 15 | sed -i "s/prefix=.*/prefix=${TARGET_DIR_SED}\nINC=-I\$(prefix)\/include/" ./Makefile 16 | sed -i "s/SHARED=.*/SHARED=no/" ./Makefile 17 | elif [ "$platform" = "darwin" ]; then 18 | - sed -i "" "s/prefix=.*/prefix=${TARGET_DIR_SED}/" ./Makefile 19 | + sed -i "s/prefix=.*/prefix=${TARGET_DIR_SED}/" ./Makefile 20 | fi 21 | make install_base 22 | 23 | @@ -358,7 +358,7 @@ cd $BUILD_DIR/vid.stab-release-* 24 | if [ "$platform" = "linux" ]; then 25 | sed -i "s/vidstab SHARED/vidstab STATIC/" ./CMakeLists.txt 26 | elif [ "$platform" = "darwin" ]; then 27 | - sed -i "" "s/vidstab SHARED/vidstab STATIC/" ./CMakeLists.txt 28 | + sed -i "s/vidstab SHARED/vidstab STATIC/" ./CMakeLists.txt 29 | fi 30 | PATH="$BIN_DIR:$PATH" cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$TARGET_DIR" 31 | make -j $jval 32 | @@ -426,35 +426,10 @@ if [ "$platform" = "linux" ]; then 33 | --extra-libs="-lpthread -lm -lz" \ 34 | --extra-ldexeflags="-static" \ 35 | --bindir="$BIN_DIR" \ 36 | - --enable-pic \ 37 | - --enable-ffplay \ 38 | - --enable-fontconfig \ 39 | - --enable-frei0r \ 40 | --enable-gpl \ 41 | - --enable-version3 \ 42 | - --enable-libass \ 43 | - --enable-libfribidi \ 44 | - --enable-libfdk-aac \ 45 | - --enable-libfreetype \ 46 | - --enable-libmp3lame \ 47 | - --enable-libopencore-amrnb \ 48 | - --enable-libopencore-amrwb \ 49 | - --enable-libopenjpeg \ 50 | - --enable-libopus \ 51 | --enable-librtmp \ 52 | - --enable-libsoxr \ 53 | - --enable-libspeex \ 54 | - --enable-libtheora \ 55 | - --enable-libvidstab \ 56 | - --enable-libvo-amrwbenc \ 57 | - --enable-libvorbis \ 58 | - --enable-libvpx \ 59 | - --enable-libwebp \ 60 | - --enable-libx264 \ 61 | - --enable-libx265 \ 62 | - --enable-libxvid \ 63 | - --enable-libzimg \ 64 | --enable-nonfree \ 65 | + --enable-libx264 \ 66 | --enable-openssl 67 | elif [ "$platform" = "darwin" ]; then 68 | [ ! -f config.status ] && PATH="$BIN_DIR:$PATH" \ 69 | @@ -466,33 +441,10 @@ elif [ "$platform" = "darwin" ]; then 70 | --extra-ldflags="-L$TARGET_DIR/lib" \ 71 | --extra-ldexeflags="-Bstatic" \ 72 | --bindir="$BIN_DIR" \ 73 | - --enable-pic \ 74 | - --enable-ffplay \ 75 | - --enable-fontconfig \ 76 | - --enable-frei0r \ 77 | --enable-gpl \ 78 | - --enable-version3 \ 79 | - --enable-libass \ 80 | - --enable-libfribidi \ 81 | - --enable-libfdk-aac \ 82 | - --enable-libfreetype \ 83 | - --enable-libmp3lame \ 84 | - --enable-libopencore-amrnb \ 85 | - --enable-libopencore-amrwb \ 86 | - --enable-libopenjpeg \ 87 | - --enable-libopus \ 88 | --enable-librtmp \ 89 | - --enable-libsoxr \ 90 | - --enable-libspeex \ 91 | - --enable-libvidstab \ 92 | - --enable-libvorbis \ 93 | - --enable-libvpx \ 94 | - --enable-libwebp \ 95 | - --enable-libx264 \ 96 | - --enable-libx265 \ 97 | - --enable-libxvid \ 98 | - --enable-libzimg \ 99 | --enable-nonfree \ 100 | + --enable-libx264 \ 101 | --enable-openssl 102 | fi 103 | 104 | -------------------------------------------------------------------------------- /setup_emacs_rootfs.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # Copy busybox 4 | sudo install -m 755 busybox/busybox "$ROOTFS_MNT/bin/busybox" 5 | # Symlink important tools, can manually symlink or use busybox install later 6 | # Getty must be a hardlink to be used as init 7 | sudo ln "$ROOTFS_MNT/bin/busybox" "$ROOTFS_MNT/sbin/getty" 8 | sudo ln -s ../bin/busybox "$ROOTFS_MNT/sbin/mount" 9 | sudo ln -s ../bin/busybox "$ROOTFS_MNT/sbin/umount" 10 | sudo cp -r ncurses/build/share/terminfo/ "$ROOTFS_MNT/share/" 11 | sudo cp -r .emacs.d "$ROOTFS_MNT/" 12 | sudo cp shutdown/shutdown "$ROOTFS_MNT/sbin/shutdown" 13 | sudo ln -s shutdown "$ROOTFS_MNT/sbin/reboot" 14 | if [ -e "./ffmpeg/bin/ffmpeg" ]; then 15 | sudo cp ffmpeg/bin/ffmpeg "$ROOTFS_MNT/bin/ffmpeg" 16 | fi 17 | -------------------------------------------------------------------------------- /shutdown/shutdown.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main(int argc, char* argv[]) { 6 | if (strcmp(argv[0], "/sbin/shutdown") == 0) { 7 | reboot(RB_POWER_OFF); 8 | return 0; 9 | } else if (strcmp(argv[0], "/sbin/reboot") == 0) { 10 | reboot(RB_AUTOBOOT); 11 | return 0; 12 | } 13 | return 1; 14 | } 15 | --------------------------------------------------------------------------------