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:
parent
1d56567c50
commit
a46c318bb8
21
build-aux/indent.sh
Executable file
21
build-aux/indent.sh
Executable 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
|
|
@ -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
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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,35 +86,34 @@ 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;
|
||||||
int si_errno;
|
int si_errno;
|
||||||
int si_code;
|
int si_code;
|
||||||
int si_trapno;
|
int si_trapno;
|
||||||
pid_t si_pid;
|
pid_t si_pid;
|
||||||
uid_t si_uid;
|
uid_t si_uid;
|
||||||
int si_status;
|
int si_status;
|
||||||
clock_t si_utime;
|
clock_t si_utime;
|
||||||
clock_t si_stime;
|
clock_t si_stime;
|
||||||
sigval_t si_value;
|
sigval_t si_value;
|
||||||
int si_int;
|
int si_int;
|
||||||
void *si_ptr;
|
void *si_ptr;
|
||||||
int si_overrun;
|
int si_overrun;
|
||||||
int si_timerid;
|
int si_timerid;
|
||||||
void *si_addr;
|
void *si_addr;
|
||||||
long si_band;
|
long si_band;
|
||||||
int si_fd;
|
int si_fd;
|
||||||
short si_addr_lsb;
|
short si_addr_lsb;
|
||||||
void *si_lower;
|
void *si_lower;
|
||||||
void *si_upper;
|
void *si_upper;
|
||||||
int si_pkey;
|
int si_pkey;
|
||||||
void *si_call_addr;
|
void *si_call_addr;
|
||||||
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;
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -77,32 +77,34 @@ 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;
|
||||||
int u_fpvalid;
|
int u_fpvalid;
|
||||||
struct user_fpregs_struct i387;
|
struct user_fpregs_struct i387;
|
||||||
unsigned long int u_tsize;
|
unsigned long int u_tsize;
|
||||||
unsigned long int u_dsize;
|
unsigned long int u_dsize;
|
||||||
unsigned long int u_ssize;
|
unsigned long int u_ssize;
|
||||||
unsigned long int start_code;
|
unsigned long int start_code;
|
||||||
unsigned long int start_stack;
|
unsigned long int start_stack;
|
||||||
long int signal;
|
long int signal;
|
||||||
int reserved;
|
int reserved;
|
||||||
struct user_regs_struct* u_ar0;
|
struct user_regs_struct *u_ar0;
|
||||||
struct user_fpregs_struct* u_fpstate;
|
struct user_fpregs_struct *u_fpstate;
|
||||||
unsigned long int magic;
|
unsigned long int magic;
|
||||||
char u_comm [32];
|
char u_comm [32];
|
||||||
int u_debugreg [8];
|
int u_debugreg [8];
|
||||||
};
|
};
|
||||||
|
|
||||||
#define PAGE_SHIFT 12
|
#define PAGE_SHIFT 12
|
||||||
#define PAGE_SIZE (1UL << PAGE_SHIFT)
|
#define PAGE_SIZE (1UL << PAGE_SHIFT)
|
||||||
#define PAGE_MASK (~(PAGE_SIZE-1))
|
#define PAGE_MASK (~(PAGE_SIZE-1))
|
||||||
#define NBPG PAGE_SIZE
|
#define NBPG PAGE_SIZE
|
||||||
#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
|
||||||
|
|
||||||
|
|
|
@ -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 ()
|
||||||
{
|
{
|
||||||
|
|
|
@ -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 ()
|
||||||
{
|
{
|
||||||
|
|
|
@ -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)
|
||||||
{
|
{
|
||||||
|
|
|
@ -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)
|
||||||
{
|
{
|
||||||
|
|
|
@ -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 ()
|
||||||
{
|
{
|
||||||
|
|
|
@ -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 ()
|
||||||
{
|
{
|
||||||
|
|
|
@ -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)
|
||||||
{
|
{
|
||||||
|
|
|
@ -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)
|
||||||
{
|
{
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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];
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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')
|
||||||
|
|
Loading…
Reference in a new issue