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
// *INDENT-OFF*
#define O_RDONLY 0
#define O_WRONLY 1
#define O_RDWR 2
@ -37,6 +38,7 @@
#define O_TRUNC 0x200
#define O_APPEND 0x400
#define O_DIRECTORY 0x10000
// *INDENT-ON*
#define FD_CLOEXEC 1

View File

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

View File

@ -31,6 +31,7 @@ typedef long stack_t;
#include <sys/types.h>
// *INDENT-OFF*
#define NSIG 30
#define SIGHUP 1
#define SIGINT 2
@ -85,35 +86,34 @@ typedef long stack_t;
#define SA_NOMASK SA_NODEFER
#define SA_ONESHOT SA_RESETHAND
typedef struct siginfo_t
{
int si_signo;
int si_errno;
int si_code;
int si_trapno;
pid_t si_pid;
uid_t si_uid;
int si_status;
clock_t si_utime;
clock_t si_stime;
sigval_t si_value;
int si_int;
void *si_ptr;
int si_overrun;
int si_timerid;
void *si_addr;
long si_band;
int si_fd;
short si_addr_lsb;
void *si_lower;
void *si_upper;
int si_pkey;
void *si_call_addr;
int si_syscall;
int si_signo;
int si_errno;
int si_code;
int si_trapno;
pid_t si_pid;
uid_t si_uid;
int si_status;
clock_t si_utime;
clock_t si_stime;
sigval_t si_value;
int si_int;
void *si_ptr;
int si_overrun;
int si_timerid;
void *si_addr;
long si_band;
int si_fd;
short si_addr_lsb;
void *si_lower;
void *si_upper;
int si_pkey;
void *si_call_addr;
int si_syscall;
unsigned int si_arch;
} siginfo_t;
// *INDENT-ON*
#if __MESC__
typedef long sighandler_t;

View File

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

View File

@ -77,32 +77,34 @@ struct user_regs_struct
long int xss;
};
// *INDENT-OFF*
struct user
{
struct user_regs_struct regs;
int u_fpvalid;
struct user_fpregs_struct i387;
unsigned long int u_tsize;
unsigned long int u_dsize;
unsigned long int u_ssize;
unsigned long int start_code;
unsigned long int start_stack;
long int signal;
int reserved;
struct user_regs_struct* u_ar0;
struct user_fpregs_struct* u_fpstate;
unsigned long int magic;
char u_comm [32];
int u_debugreg [8];
struct user_regs_struct regs;
int u_fpvalid;
struct user_fpregs_struct i387;
unsigned long int u_tsize;
unsigned long int u_dsize;
unsigned long int u_ssize;
unsigned long int start_code;
unsigned long int start_stack;
long int signal;
int reserved;
struct user_regs_struct *u_ar0;
struct user_fpregs_struct *u_fpstate;
unsigned long int magic;
char u_comm [32];
int u_debugreg [8];
};
#define PAGE_SHIFT 12
#define PAGE_SIZE (1UL << PAGE_SHIFT)
#define PAGE_MASK (~(PAGE_SIZE-1))
#define NBPG PAGE_SIZE
#define UPAGES 1
#define HOST_TEXT_START_ADDR (u.start_code)
#define HOST_STACK_END_ADDR (u.start_stack + u.u_ssize * NBPG)
#define PAGE_SHIFT 12
#define PAGE_SIZE (1UL << PAGE_SHIFT)
#define PAGE_MASK (~(PAGE_SIZE-1))
#define NBPG PAGE_SIZE
#define UPAGES 1
#define HOST_TEXT_START_ADDR (u.start_code)
#define HOST_STACK_END_ADDR (u.start_stack + u.u_ssize * NBPG)
// *INDENT-ON*
#endif // ! WITH_GLIBC

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -24,13 +24,16 @@ void
longjmp (jmp_buf env, int 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 0x8(%ebp),%esp\n\t" // env->__sp
"mov 0x0(%ebp),%ebp\n\t" // env->__bp
"jmp *%ebx\n\t" // jmp *PC
);
// *INDENT-ON*
// not reached
exit (42);
}

View File

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

View File

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

View File

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