Skip to content

Commit

Permalink
kernel: move most system #includes out of common.h
Browse files Browse the repository at this point in the history
... and into the files that actually need them. That minimizes the risk of
header conflicts, and also may be desirable for who code linking against GAP
which may for some reason or another not want to #include certain system
headers.
  • Loading branch information
fingolfin authored and wilfwilson committed Jan 17, 2020
1 parent cb7e132 commit 317e494
Show file tree
Hide file tree
Showing 39 changed files with 87 additions and 12 deletions.
2 changes: 2 additions & 0 deletions src/bits_intern.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

#include "system.h"

#include <string.h>


#define ALL_BITS_UINT (~(UInt)0)

Expand Down
5 changes: 5 additions & 0 deletions src/boehm_gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
#include "hpc/thread.h"
#endif

#include <stdio.h>
#include <stdlib.h>
#include <string.h>


#ifndef WARD_ENABLED

static inline Bag * DATA(BagHeader * bag)
Expand Down
5 changes: 0 additions & 5 deletions src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,7 @@
#include "config.h"

#include <assert.h>
#include <limits.h>
#include <setjmp.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "debug.h"

Expand Down
3 changes: 3 additions & 0 deletions src/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
#include "hpc/region.h"
#endif

#include <stdio.h>
#include <stdlib.h>

#if defined(HAVE_BACKTRACE) && defined(GAP_PRINT_BACKTRACE)
#include <execinfo.h>
#include <signal.h>
Expand Down
2 changes: 2 additions & 0 deletions src/error.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
#include "hpc/thread.h"
#endif

#include <stdio.h>


static Obj ErrorInner;
static Obj ERROR_OUTPUT = NULL;
Expand Down
3 changes: 3 additions & 0 deletions src/funcs.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
#include "hpc/thread.h"
#endif

#include <stdlib.h>


static ModuleStateOffset FuncsStateOffset = -1;

struct FuncsModuleState {
Expand Down
2 changes: 2 additions & 0 deletions src/gasman.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@

#include "bags.inc"

#include <string.h>

#ifdef GAP_MEM_CHECK
#include <sys/mman.h>
#endif
Expand Down
2 changes: 2 additions & 0 deletions src/gvars.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
#include <pthread.h>
#endif

#include <stdio.h>


#ifdef HPCGAP
#define USE_GVAR_BUCKETS
Expand Down
2 changes: 2 additions & 0 deletions src/hookintrprtr.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

#include "hpc/thread.h"

#include <string.h>


/* List of active hooks */
struct InterpreterHooks * activeHooks[HookCount];
Expand Down
2 changes: 2 additions & 0 deletions src/hpc/aobjects.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
#include "records.h"
#include "stringobj.h"

#include <stdlib.h>


static Obj TYPE_ALIST;
static Obj TYPE_AREC;
Expand Down
1 change: 1 addition & 0 deletions src/hpc/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include "hpc/misc.h"

#include <stdlib.h>
#include <string.h>

/****************************************************************************
Expand Down
1 change: 1 addition & 0 deletions src/hpc/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <errno.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <unistd.h>

Expand Down
3 changes: 2 additions & 1 deletion src/hpc/threadapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@
#include "hpc/tls.h"
#include "hpc/traverse.h"

#include <stdio.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>

#include <pthread.h>
Expand Down
2 changes: 2 additions & 0 deletions src/hpc/tls.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include "gapstate.h"
#include "hpc/thread.h"

#include <string.h>

#ifdef USE_NATIVE_TLS

__thread GAPState TLSGAPtate;
Expand Down
2 changes: 2 additions & 0 deletions src/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
#include "hpc/aobjects.h"
#endif

#include <limits.h>


/****************************************************************************
**
Expand Down
2 changes: 2 additions & 0 deletions src/libgap-api.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
#include "streams.h"
#include "stringobj.h"

#include <stdio.h>

static BOOL UsingLibGap = FALSE;

BOOL IsUsingLibGap(void)
Expand Down
4 changes: 4 additions & 0 deletions src/macfloat.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
#include "stringobj.h"
#include "sysstr.h"

#include <stdio.h>
#include <stdlib.h>


#define RequireMacFloat(funcname, op) \
RequireArgumentCondition(funcname, op, IS_MACFLOAT(op), \
"must be a macfloat")
Expand Down
2 changes: 2 additions & 0 deletions src/modules.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
#include <dlfcn.h>
#endif

#include <stdio.h>


/****************************************************************************
**
Expand Down
3 changes: 3 additions & 0 deletions src/objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
#include "hpc/traverse.h"
#endif

#include <stdio.h>
#include <stdlib.h>


enum {
MAXPRINTDEPTH = 64,
Expand Down
3 changes: 3 additions & 0 deletions src/opers.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
#include <pthread.h>
#endif

#include <stdio.h>


/****************************************************************************
**
*V TRY_NEXT_METHOD . . . . . . . . . . . . . . . . . 'TRY_NEXT_METHOD' flag
Expand Down
2 changes: 2 additions & 0 deletions src/plist.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@

#include "objects.h"

#include <string.h>

/****************************************************************************
**
*F NEW_PLIST(<type>,<plen>) . . . . . . . . . . . allocate a new plain list
Expand Down
2 changes: 2 additions & 0 deletions src/precord.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
#include "hpc/traverse.h"
#endif

#include <stdlib.h>

/****************************************************************************
**
*F * * * * * * * * * standard functions for plain records * * * * * * * * * *
Expand Down
1 change: 1 addition & 0 deletions src/profile.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

#include "hpc/thread.h"

#include <stdio.h>
#include <sys/time.h> // for gettimeofday
#include <sys/types.h>
#include <unistd.h>
Expand Down
1 change: 1 addition & 0 deletions src/saveload.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "sysfiles.h"
#include "sysopt.h"

#include <stdio.h>
#include <unistd.h>


Expand Down
2 changes: 2 additions & 0 deletions src/streams.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@

#include <dirent.h>
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <unistd.h>

Expand Down
2 changes: 2 additions & 0 deletions src/stringobj.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

#include "objects.h"

#include <string.h>


/****************************************************************************
**
Expand Down
11 changes: 7 additions & 4 deletions src/sysfiles.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,15 @@
#include "sysenv.h"
#include "sysopt.h"
#include "sysstr.h"
#include "system.h"

#include "hpc/thread.h"

#ifdef HAVE_LIBREADLINE
#include <readline/readline.h>
#endif

#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <termios.h>
#include <time.h>
#include <unistd.h>
Expand Down Expand Up @@ -69,6 +68,10 @@ typedef void sig_handler_t ( int );
#include <process.h>
#endif

#ifdef HAVE_LIBREADLINE
#include <readline/readline.h>
#endif

#include <zlib.h>


Expand Down
2 changes: 2 additions & 0 deletions src/sysfiles.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

#include "system.h"

#include <stddef.h>


/****************************************************************************
**
Expand Down
1 change: 1 addition & 0 deletions src/sysjmp.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include "system.h"

#include <setjmp.h>

/****************************************************************************
**
Expand Down
3 changes: 3 additions & 0 deletions src/sysmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
#include <fcntl.h>
#endif

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

#ifdef HAVE_MADVISE
Expand Down
2 changes: 2 additions & 0 deletions src/sysroots.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include "sysfiles.h"
#include "sysstr.h"

#include <stdlib.h>


/****************************************************************************
**
Expand Down
2 changes: 2 additions & 0 deletions src/sysroots.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

#include "common.h"

#include <stddef.h>


/****************************************************************************
**
Expand Down
2 changes: 2 additions & 0 deletions src/system.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
#include <assert.h>
#include <fcntl.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>

Expand Down
1 change: 1 addition & 0 deletions src/systime.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#include "system.h"

#include <stddef.h>
#include <sys/time.h>
#include <sys/types.h>

Expand Down
2 changes: 2 additions & 0 deletions src/trans.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ extern "C" {
#include "plist.h"
#include "saveload.h"

#include <stdio.h>

} // extern "C"

#include "permutat_intern.hh"
Expand Down
3 changes: 3 additions & 0 deletions src/vars.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
#include "hpc/guards.h"
#endif

#include <stdio.h>


/****************************************************************************
**
*V CurrLVars . . . . . . . . . . . . . . . . . . . . . local variables bag
Expand Down
2 changes: 2 additions & 0 deletions tst/testkernel/dstruct.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include <libgap-api.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

static int int_cmp(int a, int b)
{
Expand Down
4 changes: 2 additions & 2 deletions tst/testlibgap/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
*/

#include "common.h"
#include "intobj.h"

#include <intobj.h>

#include <string.h>

void records(void)
{
Expand Down
3 changes: 3 additions & 0 deletions tst/testlibgap/wsload.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
* Also shows how to directly pass command line arguments to libgap.
*/
#include "common.h"

#include <string.h>

int main(int argc, char ** argv)
{
char *args[50];
Expand Down

0 comments on commit 317e494

Please sign in to comment.