Get rid of almost all recursive includes

Simple rule: include files should never include include files.

"Notes on Programming in C", Rob Pike, February 21, 1989
<https://www.lysator.liu.se/c/pikestyle.html>
This commit is contained in:
Lassi Kortela 2019-08-09 19:00:17 +03:00
parent 0701b22d29
commit 79d44c0780
28 changed files with 200 additions and 129 deletions

View File

@ -2,21 +2,36 @@
Extra femtoLisp builtin functions
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <setjmp.h>
#include <stdarg.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include <assert.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <errno.h>
#include <math.h>
#include "llt.h"
#include "flisp.h"
#include <setjmp.h>
#include <stdarg.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "dtypes.h"
#include "utils.h"
#include "utf8.h"
#include "ios.h"
#include "socket.h"
#include "timefuncs.h"
#include "hashing.h"
#include "htable.h"
#include "htableh_inc.h"
#include "bitvector.h"
#include "dirpath.h"
#include "random.h"
#include "llt.h"
#include "flisp.h"
size_t llength(value_t v)
{

View File

@ -1,5 +1,3 @@
#include "operators.h"
#ifdef BITS64
#define NWORDS(sz) (((sz) + 7) >> 3)
#else

View File

@ -1,4 +1,6 @@
#include <stdarg.h>
#include <stdlib.h>
#include "dtypes.h"
#include "ios.h"
#include "utils.h"

View File

@ -5,7 +5,20 @@
#include <limits.h>
#include <setjmp.h>
#include "dtypes.h"
#include "utils.h"
#include "utf8.h"
#include "ios.h"
#include "socket.h"
#include "timefuncs.h"
#include "hashing.h"
#include "htable.h"
#include "htableh_inc.h"
#include "bitvector.h"
#include "dirpath.h"
#include "random.h"
#include "llt.h"
#include "flisp.h"
#include "equalhash.h"

View File

@ -1,8 +1 @@
#ifndef EQUALHASH_H
#define EQUALHASH_H
#include "htableh_inc.h"
HTPROT(equalhash)
#endif

View File

@ -29,21 +29,40 @@
Distributed under the BSD License
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <setjmp.h>
#include <stdint.h>
#include <stdarg.h>
#include <sys/types.h>
#include <assert.h>
#include <ctype.h>
#include <wctype.h>
#include <sys/types.h>
#include <locale.h>
#include <limits.h>
#include <errno.h>
#include <limits.h>
#include <locale.h>
#include <math.h>
#include <setjmp.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <wctype.h>
#include "dtypes.h"
#include "utils.h"
#include "utf8.h"
#include "ios.h"
#include "socket.h"
#include "timefuncs.h"
#include "hashing.h"
#include "htable.h"
#include "htableh_inc.h"
#include "bitvector.h"
#include "dirpath.h"
#include "random.h"
#include "llt.h"
#include "utils.h"
#include "ieee754.h"
#include "flisp.h"
#include "opcodes.h"
@ -394,7 +413,12 @@ value_t alloc_vector(size_t n, int init)
// cvalues
// --------------------------------------------------------------------
#include "htable.h"
#include "htableh_inc.h"
#include "ptrhash.h"
#include "operators.h"
#include "cvalues.h"
#include "equalhash.h"
#include "types.h"
// print

View File

@ -1,9 +1,6 @@
#ifndef FLISP_H
#define FLISP_H
#include <setjmp.h>
#include <stdint.h>
typedef uptrint_t value_t;
typedef int_t fixnum_t;
typedef uint_t ufixnum_t;
@ -122,8 +119,6 @@ typedef struct {
void fl_gc_handle(value_t *pv);
void fl_free_gc_handles(uint32_t n);
#include "opcodes.h"
// utility for iterating over all arguments in a builtin
// i=index, i0=start index, arg = var for each arg, args = arg array
// assumes "nargs" is the argument count

View File

@ -1,7 +1,23 @@
#include <assert.h>
#include <setjmp.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "dtypes.h"
#include "utils.h"
#include "utf8.h"
#include "ios.h"
#include "socket.h"
#include "timefuncs.h"
#include "hashing.h"
#include "htable.h"
#include "htableh_inc.h"
#include "bitvector.h"
#include "dirpath.h"
#include "random.h"
#include "llt.h"
#include "flisp.h"
static value_t argv_list(int argc, char *argv[])

View File

@ -1,9 +1,25 @@
/*
Hashing
*/
#include <stdlib.h>
#include <stdio.h>
#ifndef WIN32
#include <sys/param.h> /* attempt to define endianness */
#else
typedef unsigned int uint32_t;
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
#endif
#ifdef LINUX
#include <endian.h> /* attempt to define endianness */
#endif
#include <math.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include "dtypes.h"
#include "utils.h"
#include "hashing.h"

View File

@ -2,11 +2,11 @@
functions common to all hash table instantiations
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "dtypes.h"
#include "htable.h"

View File

@ -1,7 +1,5 @@
//-*- mode:c -*-
#include "htable.h"
#define HTPROT(HTNAME) \
void *HTNAME##_get(htable_t *h, void *key); \
void HTNAME##_put(htable_t *h, void *key, void *val); \

View File

@ -1,8 +1,6 @@
#ifndef __IOS_H_
#define __IOS_H_
#include <stdarg.h>
// this flag controls when data actually moves out to the underlying I/O
// channel. memory streams are a special case of this where the data
// never moves out.

View File

@ -1,11 +1,26 @@
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <assert.h>
#include <sys/types.h>
#include <assert.h>
#include <setjmp.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "dtypes.h"
#include "utils.h"
#include "utf8.h"
#include "ios.h"
#include "socket.h"
#include "timefuncs.h"
#include "hashing.h"
#include "htable.h"
#include "htableh_inc.h"
#include "bitvector.h"
#include "dirpath.h"
#include "random.h"
#include "llt.h"
#include "flisp.h"
static value_t iostreamsym, rdsym, wrsym, apsym, crsym, truncsym;

13
c/llt.h
View File

@ -1,19 +1,6 @@
#ifndef __LLT_H_
#define __LLT_H_
#include <stdarg.h>
#include "dtypes.h"
#include "utils.h"
#include "utf8.h"
#include "ios.h"
#include "socket.h"
#include "timefuncs.h"
#include "hashing.h"
#include "ptrhash.h"
#include "bitvector.h"
#include "dirpath.h"
#include "random.h"
void llt_init();
#endif

View File

@ -1,8 +1,10 @@
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <math.h>
#include <locale.h>
#include <math.h>
#include <stdarg.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include "dtypes.h"
#include "timefuncs.h"
#include "ios.h"

View File

@ -35,20 +35,6 @@ on 1 byte), but shoehorning those bytes into integers efficiently is messy.
*/
//#define SELF_TEST 1
#include <stdio.h> /* defines printf for tests */
#include <time.h> /* defines time_t for timings in the test */
#ifndef WIN32
#include <stdint.h> /* defines uint32_t etc */
#include <sys/param.h> /* attempt to define endianness */
#else
typedef unsigned int uint32_t;
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
#endif
#ifdef LINUX
#include <endian.h> /* attempt to define endianness */
#endif
/*
* My best guess at if you are big-endian or little-endian. This may
* need adjustment.

View File

@ -41,8 +41,6 @@
email: m-mat @ math.sci.hiroshima-u.ac.jp (remove space)
*/
#include <stdio.h>
/* Period parameters */
#define mtN 624
#define mtM 397

View File

@ -1,6 +1,3 @@
#ifndef OPCODES_H
#define OPCODES_H
enum {
OP_NOP = 0,
OP_DUP,
@ -167,5 +164,3 @@ enum {
#define VM_LABELS
#define VM_APPLY_LABELS
#endif
#endif

View File

@ -1,9 +1,3 @@
#include <limits.h>
#include <assert.h>
#include "dtypes.h"
#include "utils.h"
#include "ieee754.h"
extern double trunc(double x);
STATIC_INLINE double fpart(double arg) { return arg - trunc(arg); }

View File

@ -1,5 +1,3 @@
#include "ieee754.h"
extern void *memrchr(const void *s, int c, size_t n);
static htable_t printconses;

View File

@ -3,14 +3,15 @@
optimized for storing info about particular values
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "dtypes.h"
#include "ptrhash.h"
#include "htable.h"
#include "htableh_inc.h"
#define OP_EQ(x, y) ((x) == (y))

View File

@ -1,8 +1,6 @@
#ifndef __PTRHASH_H_
#define __PTRHASH_H_
#include "htableh_inc.h"
HTPROT(ptrhash)
#endif

View File

@ -1,9 +1,11 @@
/*
random numbers
*/
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include "dtypes.h"
#include "ieee754.h"
#include "utils.h"

View File

@ -1,19 +1,35 @@
/*
string functions
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <setjmp.h>
#include <stdarg.h>
#include <assert.h>
#include <ctype.h>
#include <wchar.h>
#include <wctype.h>
#include <sys/types.h>
#include <sys/time.h>
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <setjmp.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <wchar.h>
#include <wctype.h>
#include "dtypes.h"
#include "utils.h"
#include "utf8.h"
#include "ios.h"
#include "socket.h"
#include "timefuncs.h"
#include "hashing.h"
#include "htable.h"
#include "htableh_inc.h"
#include "bitvector.h"
#include "dirpath.h"
#include "random.h"
#include "llt.h"
#include "flisp.h"
value_t fl_stringp(value_t *args, u_int32_t nargs)

View File

@ -1,11 +1,26 @@
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <assert.h>
#include <sys/types.h>
#include <assert.h>
#include <setjmp.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "dtypes.h"
#include "utils.h"
#include "utf8.h"
#include "ios.h"
#include "socket.h"
#include "timefuncs.h"
#include "hashing.h"
#include "htable.h"
#include "htableh_inc.h"
#include "bitvector.h"
#include "dirpath.h"
#include "random.h"
#include "llt.h"
#include "flisp.h"
#include "equalhash.h"

View File

@ -1,5 +1,3 @@
#include "equalhash.h"
fltype_t *get_type(value_t t)
{
fltype_t *ft;

View File

@ -12,11 +12,16 @@
valid.
A UTF-8 validation routine is included.
*/
#define _XOPEN_SOURCE 700
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <wchar.h>
#include <wctype.h>
@ -30,7 +35,6 @@
#include <alloca.h>
#endif /* __FreeBSD__ && __OpenBSD__ */
#endif
#include <assert.h>
#include "utf8.h"

View File

@ -1,4 +1,3 @@
#include "dtypes.h" //for DLLEXPORT
/*
* This is an implementation of wcwidth() and wcswidth() (defined in
* IEEE Std 1002.1-2001) for Unicode.
@ -62,8 +61,6 @@
* MODIFIED TO USE uint32_t
*/
#include <stdint.h>
struct interval {
int first;
int last;
@ -122,9 +119,6 @@ static int bisearch(uint32_t ucs, const struct interval *table, int max)
* in ISO 10646.
*/
#include <stdint.h>
#include <stddef.h>
DLLEXPORT int wcwidth(uint32_t ucs)
{
/* sorted list of non-overlapping intervals of non-spacing characters */