mes: Grand indent: prepare.

* build-aux/indent.sh: New file.
* include/mes/builtins.h: Move from src/builtins.h.
* include/fcntl.h: Use // *INDENT-OFF* to prevent indent breakage.
* include/locale.h: Likewise.
* include/signal.h: Likewise.
* include/sys/stat.h: Likewise.
* include/sys/user.h: Likewise.
* lib/linux/x86-mes-gcc/crt0.c: Likewise.
* lib/linux/x86-mes-gcc/crt1.c: Likewise.
* lib/linux/x86-mes-gcc/mes.c: Likewise.
* lib/linux/x86-mes-gcc/mini.c: Likewise.
* lib/linux/x86_64-mes-gcc/crt0.c: Likewise.
* lib/linux/x86_64-mes-gcc/crt1.c: Likewise.
* lib/linux/x86_64-mes-gcc/mes.c: Likewise.
* lib/linux/x86_64-mes-gcc/mini.c: Likewise.
* lib/x86_64-mes-gcc/setjmp.c: Likewise.
* src/mes.c: Likewise.
* src/reader.c: Likewise.
This commit is contained in:
Jan Nieuwenhuizen 2019-05-13 01:07:32 +02:00
parent 1d56567c50
commit a46c318bb8
No known key found for this signature in database
GPG key ID: F3C1A0D9C1D65273
19 changed files with 96 additions and 52 deletions

21
build-aux/indent.sh Executable file
View file

@ -0,0 +1,21 @@
#! /bin/sh
# GNU Mes --- Maxwell Equations of Software
# Copyright © 2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
#
# This file is part of GNU Mes.
#
# GNU Mes is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or (at
# your option) any later version.
#
# GNU Mes is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
for i in $(find . -name '*.c' -o -name '*.h' -o -name '*.i'); do indent $i --no-tabs --line-length 110 --honour-newlines; done

View file

@ -29,6 +29,7 @@
#else // ! WITH_GLIBC #else // ! WITH_GLIBC
// *INDENT-OFF*
#define O_RDONLY 0 #define O_RDONLY 0
#define O_WRONLY 1 #define O_WRONLY 1
#define O_RDWR 2 #define O_RDWR 2
@ -37,6 +38,7 @@
#define O_TRUNC 0x200 #define O_TRUNC 0x200
#define O_APPEND 0x400 #define O_APPEND 0x400
#define O_DIRECTORY 0x10000 #define O_DIRECTORY 0x10000
// *INDENT-ON*
#define FD_CLOEXEC 1 #define FD_CLOEXEC 1

View file

@ -29,12 +29,15 @@
#else // ! WITH_GLIBC #else // ! WITH_GLIBC
// *INDENT-OFF*
#ifndef LC_ALL #ifndef LC_ALL
#define LC_CTYPE 0 #define LC_CTYPE 0
#define LC_NUMERIC 1 #define LC_NUMERIC 1
#define LC_COLLATE 3 #define LC_COLLATE 3
#define LC_ALL 6 #define LC_ALL 6
#endif #endif
// *INDENT-ON*
char * setlocale (int category, char const *locale); char * setlocale (int category, char const *locale);
#endif // ! WITH_GLIBC #endif // ! WITH_GLIBC

View file

@ -31,6 +31,7 @@ typedef long stack_t;
#include <sys/types.h> #include <sys/types.h>
// *INDENT-OFF*
#define NSIG 30 #define NSIG 30
#define SIGHUP 1 #define SIGHUP 1
#define SIGINT 2 #define SIGINT 2
@ -85,7 +86,6 @@ typedef long stack_t;
#define SA_NOMASK SA_NODEFER #define SA_NOMASK SA_NODEFER
#define SA_ONESHOT SA_RESETHAND #define SA_ONESHOT SA_RESETHAND
typedef struct siginfo_t typedef struct siginfo_t
{ {
int si_signo; int si_signo;
@ -113,7 +113,7 @@ typedef struct siginfo_t
int si_syscall; int si_syscall;
unsigned int si_arch; unsigned int si_arch;
} siginfo_t; } siginfo_t;
// *INDENT-ON*
#if __MESC__ #if __MESC__
typedef long sighandler_t; typedef long sighandler_t;

View file

@ -34,6 +34,7 @@
typedef int mode_t; typedef int mode_t;
#endif #endif
// *INDENT-OFF*
#if __i386__ #if __i386__
struct stat struct stat
{ {
@ -79,6 +80,7 @@ struct stat
unsigned long __foo1; unsigned long __foo1;
}; };
#endif #endif
// *INDENT-ON*
int chmod (char const *file_name, mode_t mode); int chmod (char const *file_name, mode_t mode);
int mkdir (char const *file_name, mode_t mode); int mkdir (char const *file_name, mode_t mode);

View file

@ -77,6 +77,7 @@ struct user_regs_struct
long int xss; long int xss;
}; };
// *INDENT-OFF*
struct user struct user
{ {
struct user_regs_struct regs; struct user_regs_struct regs;
@ -103,6 +104,7 @@ struct user
#define UPAGES 1 #define UPAGES 1
#define HOST_TEXT_START_ADDR (u.start_code) #define HOST_TEXT_START_ADDR (u.start_code)
#define HOST_STACK_END_ADDR (u.start_stack + u.u_ssize * NBPG) #define HOST_STACK_END_ADDR (u.start_stack + u.u_ssize * NBPG)
// *INDENT-ON*
#endif // ! WITH_GLIBC #endif // ! WITH_GLIBC

View file

@ -26,6 +26,7 @@
#include <mes/lib-mini.h> #include <mes/lib-mini.h>
int _main (int argc, char *argv[]); int _main (int argc, char *argv[]);
// *INDENT-OFF*
void void
_start () _start ()
{ {

View file

@ -21,6 +21,7 @@
#include <mes/lib-mini.h> #include <mes/lib-mini.h>
//int main (int argc, char *argv[], char *envp[]); //int main (int argc, char *argv[], char *envp[]);
// *INDENT-OFF*
void void
_start () _start ()
{ {

View file

@ -21,6 +21,7 @@
#include <errno.h> #include <errno.h>
#include <linux/x86/syscall.h> #include <linux/x86/syscall.h>
// *INDENT-OFF*
long long
_sys_call (long sys_call) _sys_call (long sys_call)
{ {

View file

@ -21,6 +21,7 @@
#define SYS_exit "0x01" #define SYS_exit "0x01"
#define SYS_write "0x04" #define SYS_write "0x04"
// *INDENT-OFF*
void void
_exit (int code) _exit (int code)
{ {

View file

@ -29,6 +29,7 @@ int main (int argc, char *argv[]);
// gcc x86_64 calling convention: // gcc x86_64 calling convention:
// rdi, rsi, rdx, rcx, r8, r9, <stack0>, <stack1> // rdi, rsi, rdx, rcx, r8, r9, <stack0>, <stack1>
// *INDENT-OFF*
void void
_start () _start ()
{ {

View file

@ -24,6 +24,7 @@
// gcc x86_64 calling convention: // gcc x86_64 calling convention:
// rdi, rsi, rdx, rcx, r8, r9, <stack0>, <stack1> // rdi, rsi, rdx, rcx, r8, r9, <stack0>, <stack1>
// *INDENT-OFF*
void void
_start () _start ()
{ {

View file

@ -28,6 +28,7 @@
// #define R0 rax // #define R0 rax
// #define R1 rdi // #define R1 rdi
// *INDENT-OFF*
long long
_sys_call (long sys_call) _sys_call (long sys_call)
{ {

View file

@ -21,6 +21,7 @@
#define SYS_exit "0x3c" #define SYS_exit "0x3c"
#define SYS_write "0x01" #define SYS_write "0x01"
// *INDENT-OFF*
void void
_exit (int code) _exit (int code)
{ {

View file

@ -24,13 +24,16 @@ void
longjmp (jmp_buf env, int val) longjmp (jmp_buf env, int val)
{ {
val = val == 0 ? 1 : val; val = val == 0 ? 1 : val;
asm ("mov 0x8(%ebp),%ebp\n\t" // env* // *INDENT-OFF*
asm (
"mov 0x8(%ebp),%ebp\n\t" // env*
"mov 0x4(%ebp),%ebx\n\t" // env->__pc "mov 0x4(%ebp),%ebx\n\t" // env->__pc
"mov 0x8(%ebp),%esp\n\t" // env->__sp "mov 0x8(%ebp),%esp\n\t" // env->__sp
"mov 0x0(%ebp),%ebp\n\t" // env->__bp "mov 0x0(%ebp),%ebp\n\t" // env->__bp
"jmp *%ebx\n\t" // jmp *PC "jmp *%ebx\n\t" // jmp *PC
); );
// *INDENT-ON*
// not reached // not reached
exit (42); exit (42);
} }

View file

@ -24,12 +24,14 @@ void
longjmp (jmp_buf env, int val) longjmp (jmp_buf env, int val)
{ {
val = val == 0 ? 1 : val; val = val == 0 ? 1 : val;
// *INDENT-OFF*
asm ( asm (
"mov 0x00(%rdi),%rbp\n\t" // env->__bp "mov 0x00(%rdi),%rbp\n\t" // env->__bp
"mov 0x08(%rdi),%rbx\n\t" // env->__pc "mov 0x08(%rdi),%rbx\n\t" // env->__pc
"mov 0x10(%rdi),%rsp\n\t" // env->__sp "mov 0x10(%rdi),%rsp\n\t" // env->__sp
"jmp *%rbx\n\t" // jmp *PC "jmp *%rbx\n\t" // jmp *PC
); );
// *INDENT-ON*
// not reached // not reached
exit (42); exit (42);
} }
@ -38,10 +40,12 @@ int
setjmp (jmp_buf env) setjmp (jmp_buf env)
{ {
long *p; long *p;
// *INDENT-OFF*
asm ("mov %%rbp,%0" asm ("mov %%rbp,%0"
: "=r" (p) : "=r" (p)
: //no inputs "" : //no inputs ""
); );
// *INDENT-ON*
env[0].__bp = p; env[0].__bp = p;
env[0].__pc = p[1]; env[0].__pc = p[1];
env[0].__sp = p[0]; env[0].__sp = p[0];

View file

@ -385,7 +385,7 @@ struct scm *g_news = 0;
// CONSTANT cell_test 118 // CONSTANT cell_test 118
#define cell_test 118 #define cell_test 118
#include "builtins.h" #include "mes/builtins.h"
#define TYPE(x) g_cells[x].type #define TYPE(x) g_cells[x].type
#define CAR(x) g_cells[x].car #define CAR(x) g_cells[x].car

View file

@ -232,10 +232,9 @@ reader_read_hash (int c, SCM a)
if (c == ':') if (c == ':')
{ {
SCM x = reader_read_identifier_or_number (readchar ()); SCM x = reader_read_identifier_or_number (readchar ());
SCM msg = MAKE_STRING0 ("keyword perifx ':' not followed by a symbol: ");
if (TYPE (x) == TNUMBER) if (TYPE (x) == TNUMBER)
error (cell_symbol_system_error, // READ error error (cell_symbol_system_error, cons (msg, x));
cons (MAKE_STRING0 ("keyword perifx ':' not followed by a symbol: "),
x));
return symbol_to_keyword (x); return symbol_to_keyword (x);
} }
if (c == 'b') if (c == 'b')